@@ -663,37 +663,24 @@ void SILParser::convertRequirements(ArrayRef<RequirementRepr> From,
663663 }
664664}
665665
666- static bool parseDeclSILOptional (bool *isTransparent,
667- IsSerialized_t *isSerialized,
668- bool *isCanonical,
669- bool *hasOwnershipSSA,
670- IsThunk_t *isThunk,
671- IsDynamicallyReplaceable_t *isDynamic,
672- IsDistributed_t *isDistributed,
673- IsRuntimeAccessible_t *isRuntimeAccessible,
674- ForceEnableLexicalLifetimes_t *forceEnableLexicalLifetimes,
675- UseStackForPackMetadata_t *useStackForPackMetadata,
676- bool *hasUnsafeNonEscapableResult,
677- IsExactSelfClass_t *isExactSelfClass,
678- SILFunction **dynamicallyReplacedFunction,
679- SILFunction **usedAdHocRequirementWitness,
680- Identifier *objCReplacementFor,
681- SILFunction::Purpose *specialPurpose,
682- Inline_t *inlineStrategy,
683- OptimizationMode *optimizationMode,
684- PerformanceConstraints *perfConstraints,
685- bool *markedAsUsed,
686- StringRef *section,
687- bool *isLet,
688- bool *isWeakImported,
689- bool *needStackProtection,
690- AvailabilityContext *availability,
691- bool *isWithoutActuallyEscapingThunk,
692- SmallVectorImpl<std::string> *Semantics,
693- SmallVectorImpl<ParsedSpecAttr> *SpecAttrs,
694- ValueDecl **ClangDecl,
695- EffectsKind *MRK,
696- SILParser &SP, SILModule &M) {
666+ static bool parseDeclSILOptional (
667+ bool *isTransparent, IsSerialized_t *isSerialized, bool *isCanonical,
668+ bool *hasOwnershipSSA, bool *hasResultDependsOnSelf, IsThunk_t *isThunk,
669+ IsDynamicallyReplaceable_t *isDynamic, IsDistributed_t *isDistributed,
670+ IsRuntimeAccessible_t *isRuntimeAccessible,
671+ ForceEnableLexicalLifetimes_t *forceEnableLexicalLifetimes,
672+ UseStackForPackMetadata_t *useStackForPackMetadata,
673+ bool *hasUnsafeNonEscapableResult, IsExactSelfClass_t *isExactSelfClass,
674+ SILFunction **dynamicallyReplacedFunction,
675+ SILFunction **usedAdHocRequirementWitness, Identifier *objCReplacementFor,
676+ SILFunction::Purpose *specialPurpose, Inline_t *inlineStrategy,
677+ OptimizationMode *optimizationMode, PerformanceConstraints *perfConstraints,
678+ bool *markedAsUsed, StringRef *section, bool *isLet, bool *isWeakImported,
679+ bool *needStackProtection, AvailabilityContext *availability,
680+ bool *isWithoutActuallyEscapingThunk,
681+ SmallVectorImpl<std::string> *Semantics,
682+ SmallVectorImpl<ParsedSpecAttr> *SpecAttrs, ValueDecl **ClangDecl,
683+ EffectsKind *MRK, SILParser &SP, SILModule &M) {
697684 while (SP.P .consumeIf (tok::l_square)) {
698685 if (isLet && SP.P .Tok .is (tok::kw_let)) {
699686 *isLet = true ;
@@ -729,6 +716,9 @@ static bool parseDeclSILOptional(bool *isTransparent,
729716 *isCanonical = true ;
730717 else if (hasOwnershipSSA && SP.P .Tok .getText () == " ossa" )
731718 *hasOwnershipSSA = true ;
719+ else if (hasResultDependsOnSelf &&
720+ SP.P .Tok .getText () == " _resultDependsOnSelf" )
721+ *hasResultDependsOnSelf = true ;
732722 else if (needStackProtection && SP.P .Tok .getText () == " stack_protection" )
733723 *needStackProtection = true ;
734724 else if (isThunk && SP.P .Tok .getText () == " thunk" )
@@ -6883,9 +6873,11 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
68836873 bool foundEagerMove = false ;
68846874 bool foundReborrow = false ;
68856875 bool hasPointerEscape = false ;
6886- while (auto attributeName = parseOptionalAttribute (
6887- {" noImplicitCopy" , " _lexical" , " _eagerMove" ,
6888- " closureCapture" , " reborrow" , " pointer_escape" })) {
6876+ bool hasResultDependsOn = false ;
6877+ while (
6878+ auto attributeName = parseOptionalAttribute (
6879+ {" noImplicitCopy" , " _lexical" , " _eagerMove" , " closureCapture" ,
6880+ " reborrow" , " pointer_escape" , " _resultDependsOn" })) {
68896881 if (*attributeName == " noImplicitCopy" )
68906882 foundNoImplicitCopy = true ;
68916883 else if (*attributeName == " _lexical" )
@@ -6898,6 +6890,8 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
68986890 foundReborrow = true ;
68996891 else if (*attributeName == " pointer_escape" )
69006892 hasPointerEscape = true ;
6893+ else if (*attributeName == " _resultDependsOn" )
6894+ hasResultDependsOn = true ;
69016895 else {
69026896 llvm_unreachable (" Unexpected attribute!" );
69036897 }
@@ -6930,6 +6924,7 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
69306924 fArg ->setLifetimeAnnotation (lifetime);
69316925 fArg ->setReborrow (foundReborrow);
69326926 fArg ->setHasPointerEscape (hasPointerEscape);
6927+ fArg ->setHasResultDependsOn (hasResultDependsOn);
69336928 Arg = fArg ;
69346929
69356930 // Today, we construct the ownership kind straight from the function
@@ -7013,6 +7008,7 @@ bool SILParserState::parseDeclSIL(Parser &P) {
70137008 bool hasUnsafeNonEscapableResult = false ;
70147009 IsExactSelfClass_t isExactSelfClass = IsNotExactSelfClass;
70157010 bool hasOwnershipSSA = false ;
7011+ bool hasResultDependsOnSelf = false ;
70167012 IsThunk_t isThunk = IsNotThunk;
70177013 SILFunction::Purpose specialPurpose = SILFunction::Purpose::None;
70187014 bool isWeakImported = false ;
@@ -7034,9 +7030,9 @@ bool SILParserState::parseDeclSIL(Parser &P) {
70347030 if (parseSILLinkage (FnLinkage, P) ||
70357031 parseDeclSILOptional (
70367032 &isTransparent, &isSerialized, &isCanonical, &hasOwnershipSSA,
7037- &isThunk , &isDynamic , &isDistributed , &isRuntimeAccessible ,
7038- &forceEnableLexicalLifetimes , &useStackForPackMetadata ,
7039- &hasUnsafeNonEscapableResult,
7033+ &hasResultDependsOnSelf , &isThunk , &isDynamic , &isDistributed ,
7034+ &isRuntimeAccessible , &forceEnableLexicalLifetimes ,
7035+ &useStackForPackMetadata, & hasUnsafeNonEscapableResult,
70407036 &isExactSelfClass, &DynamicallyReplacedFunction,
70417037 &AdHocWitnessFunction, &objCReplacementFor, &specialPurpose,
70427038 &inlineStrategy, &optimizationMode, &perfConstr, &markedAsUsed,
@@ -7070,6 +7066,7 @@ bool SILParserState::parseDeclSIL(Parser &P) {
70707066 FunctionState.F ->setWasDeserializedCanonical (isCanonical);
70717067 if (!hasOwnershipSSA)
70727068 FunctionState.F ->setOwnershipEliminated ();
7069+ FunctionState.F ->setHasResultDependsOnSelf (hasResultDependsOnSelf);
70737070 FunctionState.F ->setThunk (IsThunk_t (isThunk));
70747071 FunctionState.F ->setIsDynamic (isDynamic);
70757072 FunctionState.F ->setIsDistributed (isDistributed);
@@ -7290,9 +7287,9 @@ bool SILParserState::parseSILGlobal(Parser &P) {
72907287 parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr , nullptr ,
72917288 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
72927289 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7293- nullptr , nullptr , nullptr , nullptr , &isLet, nullptr ,
7290+ nullptr , nullptr , nullptr , nullptr , nullptr , &isLet ,
72947291 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7295- nullptr , State, M) ||
7292+ nullptr , nullptr , State, M) ||
72967293 P.parseToken (tok::at_sign, diag::expected_sil_value_name) ||
72977294 P.parseIdentifier (GlobalName, NameLoc, /* diagnoseDollarPrefix=*/ false ,
72987295 diag::expected_sil_value_name) ||
@@ -7344,7 +7341,7 @@ bool SILParserState::parseSILProperty(Parser &P) {
73447341 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
73457342 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
73467343 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7347- nullptr , SP, M))
7344+ nullptr , nullptr , SP, M))
73487345 return true ;
73497346
73507347 ValueDecl *VD;
@@ -7414,7 +7411,7 @@ bool SILParserState::parseSILVTable(Parser &P) {
74147411 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
74157412 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
74167413 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7417- nullptr , VTableState, M))
7414+ nullptr , nullptr , VTableState, M))
74187415 return true ;
74197416
74207417 // Parse the class name.
@@ -7525,7 +7522,7 @@ bool SILParserState::parseSILMoveOnlyDeinit(Parser &parser) {
75257522 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
75267523 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
75277524 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7528- nullptr , moveOnlyDeinitTableState, M))
7525+ nullptr , nullptr , moveOnlyDeinitTableState, M))
75297526 return true ;
75307527
75317528 // Parse the class name.
@@ -8012,7 +8009,7 @@ bool SILParserState::parseSILWitnessTable(Parser &P) {
80128009 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
80138010 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
80148011 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8015- nullptr , WitnessState, M))
8012+ nullptr , nullptr , WitnessState, M))
80168013 return true ;
80178014
80188015 // Parse the protocol conformance.
0 commit comments