Skip to content

Remove resultDependsOn/resultDependsOnSelf #74132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions SwiftCompilerSources/Sources/SIL/Argument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ final public class FunctionArgument : Argument {
return index < parentFunction.numIndirectResultArguments
}

public var hasResultDependsOn : Bool {
return bridged.hasResultDependsOn()
}

/// If the function's result depends on this argument, return the
/// kind of dependence.
public var resultDependence: LifetimeDependenceConvention? {
Expand Down
4 changes: 0 additions & 4 deletions SwiftCompilerSources/Sources/SIL/Function.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,6 @@ extension Function {
public var hasResultDependence: Bool {
convention.resultDependencies != nil
}

public var hasResultDependsOnSelf: Bool {
return bridged.hasResultDependsOnSelf()
}
}

public struct ArgumentTypeArray : RandomAccessCollection, FormattedLikeArray {
Expand Down
1 change: 0 additions & 1 deletion include/swift/AST/ASTBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,6 @@ enum ENUM_EXTENSIBILITY_ATTR(open) BridgedAttributedTypeSpecifier : size_t {
BridgedAttributedTypeSpecifierLegacyOwned,
BridgedAttributedTypeSpecifierConst,
BridgedAttributedTypeSpecifierIsolated,
BridgedAttributedTypeSpecifierResultDependsOn,
BridgedAttributedTypeSpecifierTransferring,
BridgedAttributedTypeSpecifierSending,
};
Expand Down
17 changes: 0 additions & 17 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6616,8 +6616,6 @@ class ParamDecl : public VarDecl {

/// Whether or not this parameter is '_const'.
IsCompileTimeConst = 1 << 1,

HasResultDependsOn = 1 << 2,
};

llvm::PointerIntPair<Identifier, 3, OptionSet<ArgumentNameFlags>>
Expand Down Expand Up @@ -6656,9 +6654,6 @@ class ParamDecl : public VarDecl {
/// Whether or not this parameter is 'isolated'.
IsIsolated = 1 << 2,

/// Whether or not this paramater is '_resultDependsOn'
IsResultDependsOn = 1 << 3,

/// Whether or not this parameter is 'sending'.
IsSending = 1 << 4,
};
Expand Down Expand Up @@ -6961,18 +6956,6 @@ class ParamDecl : public VarDecl {
ArgumentNameAndFlags.setInt(flags);
}

bool hasResultDependsOn() const {
return ArgumentNameAndFlags.getInt().contains(
ArgumentNameFlags::HasResultDependsOn);
}

void setResultDependsOn(bool value = true) {
auto flags = ArgumentNameAndFlags.getInt();
flags = value ? flags | ArgumentNameFlags::HasResultDependsOn
: flags - ArgumentNameFlags::HasResultDependsOn;
ArgumentNameAndFlags.setInt(flags);
}

/// Does this parameter reject temporary pointer conversions?
bool isNonEphemeral() const;

Expand Down
3 changes: 0 additions & 3 deletions include/swift/AST/DeclAttr.def
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,6 @@ DECL_ATTR(storageRestrictions, StorageRestrictions,
CONTEXTUAL_SIMPLE_DECL_ATTR(actor, Actor,
DeclModifier | OnClass | ConcurrencyOnly | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
102)
CONTEXTUAL_SIMPLE_DECL_ATTR(_resultDependsOnSelf, ResultDependsOnSelf,
OnFunc | DeclModifier | UserInaccessible | ABIBreakingToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
150)
SIMPLE_DECL_ATTR(_staticExclusiveOnly, StaticExclusiveOnly,
OnStruct | UserInaccessible | ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
151)
Expand Down
7 changes: 0 additions & 7 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -7931,13 +7931,6 @@ ERROR(referencebindings_binding_must_have_initial_value,none,
ERROR(referencebindings_binding_must_be_to_lvalue,none,
"%0 bindings must be bound to an lvalue", (StringRef))

//------------------------------------------------------------------------------
// MARK: resultDependsOn Errors
//------------------------------------------------------------------------------

ERROR(result_depends_on_no_result,none,
"Incorrect use of %0 with no result", (StringRef))

//------------------------------------------------------------------------------
// MARK: Pack Iteration Diagnostics
//------------------------------------------------------------------------------
Expand Down
17 changes: 0 additions & 17 deletions include/swift/AST/TypeRepr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,6 @@ class SpecifierTypeRepr : public TypeRepr {
return T->getKind() == TypeReprKind::Ownership ||
T->getKind() == TypeReprKind::Isolated ||
T->getKind() == TypeReprKind::CompileTimeConst ||
T->getKind() == TypeReprKind::ResultDependsOn ||
T->getKind() == TypeReprKind::LifetimeDependentReturn ||
T->getKind() == TypeReprKind::Transferring ||
T->getKind() == TypeReprKind::Sending;
Expand Down Expand Up @@ -1188,21 +1187,6 @@ class CompileTimeConstTypeRepr : public SpecifierTypeRepr {
static bool classof(const CompileTimeConstTypeRepr *T) { return true; }
};

/// A lifetime dependent type.
/// \code
/// x : _resultDependsOn Int
/// \endcode
class ResultDependsOnTypeRepr : public SpecifierTypeRepr {
public:
ResultDependsOnTypeRepr(TypeRepr *Base, SourceLoc InOutLoc)
: SpecifierTypeRepr(TypeReprKind::ResultDependsOn, Base, InOutLoc) {}

static bool classof(const TypeRepr *T) {
return T->getKind() == TypeReprKind::ResultDependsOn;
}
static bool classof(const ResultDependsOnTypeRepr *T) { return true; }
};

/// A transferring type.
/// \code
/// x : transferring Int
Expand Down Expand Up @@ -1637,7 +1621,6 @@ inline bool TypeRepr::isSimple() const {
case TypeReprKind::Sending:
case TypeReprKind::Placeholder:
case TypeReprKind::CompileTimeConst:
case TypeReprKind::ResultDependsOn:
case TypeReprKind::LifetimeDependentReturn:
return true;
}
Expand Down
1 change: 0 additions & 1 deletion include/swift/AST/TypeReprNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ ABSTRACT_TYPEREPR(Specifier, TypeRepr)
SPECIFIER_TYPEREPR(Ownership, SpecifierTypeRepr)
SPECIFIER_TYPEREPR(Isolated, SpecifierTypeRepr)
SPECIFIER_TYPEREPR(CompileTimeConst, SpecifierTypeRepr)
SPECIFIER_TYPEREPR(ResultDependsOn, SpecifierTypeRepr)
SPECIFIER_TYPEREPR(Transferring, SpecifierTypeRepr)
SPECIFIER_TYPEREPR(Sending, SpecifierTypeRepr)
TYPEREPR(Fixed, TypeRepr)
Expand Down
20 changes: 7 additions & 13 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2226,9 +2226,8 @@ class ParameterTypeFlags {
NoDerivative = 1 << 6,
Isolated = 1 << 7,
CompileTimeConst = 1 << 8,
ResultDependsOn = 1 << 9,
Sending = 1 << 10,
NumBits = 11
Sending = 1 << 9,
NumBits = 10
};
OptionSet<ParameterFlags> value;
static_assert(NumBits <= 8*sizeof(OptionSet<ParameterFlags>), "overflowed");
Expand All @@ -2243,22 +2242,20 @@ class ParameterTypeFlags {

ParameterTypeFlags(bool variadic, bool autoclosure, bool nonEphemeral,
ParamSpecifier specifier, bool isolated, bool noDerivative,
bool compileTimeConst, bool hasResultDependsOn,
bool isSending)
bool compileTimeConst, bool isSending)
: value((variadic ? Variadic : 0) | (autoclosure ? AutoClosure : 0) |
(nonEphemeral ? NonEphemeral : 0) |
uint8_t(specifier) << SpecifierShift | (isolated ? Isolated : 0) |
(noDerivative ? NoDerivative : 0) |
(compileTimeConst ? CompileTimeConst : 0) |
(hasResultDependsOn ? ResultDependsOn : 0) |
(isSending ? Sending : 0)) {}

/// Create one from what's present in the parameter type
inline static ParameterTypeFlags
fromParameterType(Type paramTy, bool isVariadic, bool isAutoClosure,
bool isNonEphemeral, ParamSpecifier ownership,
bool isolated, bool isNoDerivative, bool compileTimeConst,
bool hasResultDependsOn, bool isSending);
bool isSending);

bool isNone() const { return !value; }
bool isVariadic() const { return value.contains(Variadic); }
Expand All @@ -2270,7 +2267,6 @@ class ParameterTypeFlags {
bool isIsolated() const { return value.contains(Isolated); }
bool isCompileTimeConst() const { return value.contains(CompileTimeConst); }
bool isNoDerivative() const { return value.contains(NoDerivative); }
bool hasResultDependsOn() const { return value.contains(ResultDependsOn); }
bool isSending() const { return value.contains(Sending); }

/// Get the spelling of the parameter specifier used on the parameter.
Expand Down Expand Up @@ -2433,7 +2429,6 @@ class YieldTypeFlags {
/*nonEphemeral*/ false, getOwnershipSpecifier(),
/*isolated*/ false, /*noDerivative*/ false,
/*compileTimeConst*/ false,
/*hasResultDependsOn*/ false,
/*is transferring*/ false);
}

Expand Down Expand Up @@ -7771,7 +7766,7 @@ inline TupleTypeElt TupleTypeElt::getWithType(Type T) const {
inline ParameterTypeFlags ParameterTypeFlags::fromParameterType(
Type paramTy, bool isVariadic, bool isAutoClosure, bool isNonEphemeral,
ParamSpecifier ownership, bool isolated, bool isNoDerivative,
bool compileTimeConst, bool hasResultDependsOn, bool isSending) {
bool compileTimeConst, bool isSending) {
// FIXME(Remove InOut): The last caller that needs this is argument
// decomposition. Start by enabling the assertion there and fixing up those
// callers, then remove this, then remove
Expand All @@ -7781,9 +7776,8 @@ inline ParameterTypeFlags ParameterTypeFlags::fromParameterType(
ownership == ParamSpecifier::InOut);
ownership = ParamSpecifier::InOut;
}
return {isVariadic, isAutoClosure, isNonEphemeral,
ownership, isolated, isNoDerivative,
compileTimeConst, hasResultDependsOn, isSending};
return {isVariadic, isAutoClosure, isNonEphemeral, ownership,
isolated, isNoDerivative, compileTimeConst, isSending};
}

inline const Type *BoundGenericType::getTrailingObjectsPointer() const {
Expand Down
10 changes: 1 addition & 9 deletions include/swift/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -1200,18 +1200,14 @@ class Parser {
Tok.isContextualKeyword("isolated") ||
Tok.isContextualKeyword("_const"))
return true;
if (Context.LangOpts.hasFeature(Feature::NonescapableTypes) &&
Tok.isContextualKeyword("_resultDependsOn"))
return true;
if (Context.LangOpts.hasFeature(Feature::TransferringArgsAndResults) &&
Tok.isContextualKeyword("transferring"))
return true;
if (Context.LangOpts.hasFeature(Feature::SendingArgsAndResults) &&
Tok.isContextualKeyword("sending"))
return true;
if (Context.LangOpts.hasFeature(Feature::NonescapableTypes) &&
(Tok.isContextualKeyword("_resultDependsOn") ||
isLifetimeDependenceToken()))
isLifetimeDependenceToken())
return true;
return false;
}
Expand Down Expand Up @@ -1257,7 +1253,6 @@ class Parser {
SourceLoc SpecifierLoc;
SourceLoc IsolatedLoc;
SourceLoc ConstLoc;
SourceLoc ResultDependsOnLoc;
SourceLoc TransferringLoc;
SourceLoc SendingLoc;
SmallVector<TypeOrCustomAttr> Attributes;
Expand Down Expand Up @@ -1571,9 +1566,6 @@ class Parser {
/// The location of the '_const' keyword, if present.
SourceLoc CompileConstLoc;

/// The location of the '_resultDependsOn' keyword, if present.
SourceLoc ResultDependsOnLoc;

/// The location of the 'transferring' keyword if present.
SourceLoc TransferringLoc;

Expand Down
12 changes: 1 addition & 11 deletions include/swift/SIL/SILArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,13 @@ class SILFunctionArgument : public SILArgument {
ValueOwnershipKind ownershipKind, const ValueDecl *decl = nullptr,
bool isNoImplicitCopy = false,
LifetimeAnnotation lifetimeAnnotation = LifetimeAnnotation::None,
bool isCapture = false, bool isParameterPack = false,
bool hasResultDependsOn = false)
bool isCapture = false, bool isParameterPack = false)
: SILArgument(ValueKind::SILFunctionArgument, parentBlock, type,
ownershipKind, decl) {
sharedUInt32().SILFunctionArgument.noImplicitCopy = isNoImplicitCopy;
sharedUInt32().SILFunctionArgument.lifetimeAnnotation = lifetimeAnnotation;
sharedUInt32().SILFunctionArgument.closureCapture = isCapture;
sharedUInt32().SILFunctionArgument.parameterPack = isParameterPack;
sharedUInt32().SILFunctionArgument.hasResultDependsOn = hasResultDependsOn;
}

// A special constructor, only intended for use in
Expand Down Expand Up @@ -426,14 +424,6 @@ class SILFunctionArgument : public SILArgument {
sharedUInt32().SILFunctionArgument.lifetimeAnnotation = newValue;
}

bool hasResultDependsOn() const {
return sharedUInt32().SILFunctionArgument.hasResultDependsOn;
}

void setHasResultDependsOn(bool flag = true) {
sharedUInt32().SILFunctionArgument.hasResultDependsOn = flag;
}

bool isSending() const {
return getKnownParameterInfo().hasOption(SILParameterInfo::Sending);
}
Expand Down
2 changes: 0 additions & 2 deletions include/swift/SIL/SILBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ struct BridgedFunction {
BRIDGED_INLINE bool isGeneric() const;
BRIDGED_INLINE bool hasSemanticsAttr(BridgedStringRef attrName) const;
BRIDGED_INLINE bool hasUnsafeNonEscapableResult() const;
BRIDGED_INLINE bool hasResultDependsOnSelf() const;
bool mayBindDynamicSelf() const;
BRIDGED_INLINE EffectsKind getEffectAttribute() const;
BRIDGED_INLINE PerformanceConstraints getPerformanceConstraints() const;
Expand Down Expand Up @@ -1026,7 +1025,6 @@ struct BridgedArgument {
BRIDGED_INLINE swift::SILArgument * _Nonnull getArgument() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedBasicBlock getParent() const;
BRIDGED_INLINE bool isReborrow() const;
BRIDGED_INLINE bool hasResultDependsOn() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedNullableVarDecl getVarDecl() const;
BRIDGED_INLINE void copyFlags(BridgedArgument fromArgument) const;
};
Expand Down
9 changes: 0 additions & 9 deletions include/swift/SIL/SILBridgingImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,6 @@ BridgedBasicBlock BridgedArgument::getParent() const {
return {getArgument()->getParent()};
}

bool BridgedArgument::hasResultDependsOn() const {
auto *fArg = static_cast<swift::SILFunctionArgument*>(getArgument());
return fArg->hasResultDependsOn();
}

bool BridgedArgument::isReborrow() const { return getArgument()->isReborrow(); }

BridgedNullableVarDecl BridgedArgument::getVarDecl() const {
Expand Down Expand Up @@ -692,10 +687,6 @@ bool BridgedFunction::hasUnsafeNonEscapableResult() const {
return getFunction()->hasUnsafeNonEscapableResult();
}

bool BridgedFunction::hasResultDependsOnSelf() const {
return getFunction()->hasResultDependsOnSelf();
}

BridgedFunction::EffectsKind BridgedFunction::getEffectAttribute() const {
return (EffectsKind)getFunction()->getEffectsKind();
}
Expand Down
7 changes: 0 additions & 7 deletions include/swift/SIL/SILFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,6 @@ class SILFunction
/// lifetime-dependence on an argument.
unsigned HasUnsafeNonEscapableResult : 1;

unsigned HasResultDependsOnSelf : 1;

/// True, if this function or a caller (transitively) has a performance
/// constraint.
/// If true, optimizations must not introduce new runtime calls or metadata
Expand Down Expand Up @@ -758,11 +756,6 @@ class SILFunction
HasUnsafeNonEscapableResult = value;
}

bool hasResultDependsOnSelf() const { return HasResultDependsOnSelf; }

void setHasResultDependsOnSelf(bool flag = true) {
HasResultDependsOnSelf = flag;
}
/// Returns true if this is a reabstraction thunk of escaping function type
/// whose single argument is a potentially non-escaping closure. i.e. the
/// thunks' function argument may itself have @inout_aliasable parameters.
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SIL/SILNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class alignas(8) SILNode :
SHARED_FIELD(PointerToAddressInst, uint32_t alignment);
SHARED_FIELD(SILFunctionArgument, uint32_t noImplicitCopy : 1,
lifetimeAnnotation : 2, closureCapture : 1,
parameterPack : 1, hasResultDependsOn : 1);
parameterPack : 1);

// Do not use `_sharedUInt32_private` outside of SILNode.
} _sharedUInt32_private;
Expand Down
3 changes: 0 additions & 3 deletions lib/AST/ASTBridging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2236,9 +2236,6 @@ BridgedSpecifierTypeRepr BridgedSpecifierTypeRepr_createParsed(
case BridgedAttributedTypeSpecifierIsolated: {
return new (context) IsolatedTypeRepr(baseType, loc);
}
case BridgedAttributedTypeSpecifierResultDependsOn: {
return new (context) ResultDependsOnTypeRepr(baseType, loc);
}
}
}

Expand Down
7 changes: 0 additions & 7 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3462,13 +3462,6 @@ class PrintTypeRepr : public TypeReprVisitor<PrintTypeRepr, void, StringRef>,
printFoot();
}

void visitResultDependsOnTypeRepr(ResultDependsOnTypeRepr *T,
StringRef label) {
printCommon("_resultDependsOn", label);
printRec(T->getBase());
printFoot();
}

void visitOptionalTypeRepr(OptionalTypeRepr *T, StringRef label) {
printCommon("type_optional", label);
printRec(T->getBase());
Expand Down
3 changes: 0 additions & 3 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3783,9 +3783,6 @@ static void printParameterFlags(ASTPrinter &printer,
printer.printKeyword("isolated", options, " ");
}

if (flags.hasResultDependsOn())
printer.printKeyword("_resultDependsOn", options, " ");

if (!options.excludeAttrKind(TypeAttrKind::Escaping) && escaping)
printer.printKeyword("@escaping", options, " ");

Expand Down
4 changes: 0 additions & 4 deletions lib/AST/ASTWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2348,10 +2348,6 @@ bool Traversal::visitCompileTimeConstTypeRepr(CompileTimeConstTypeRepr *T) {
return doIt(T->getBase());
}

bool Traversal::visitResultDependsOnTypeRepr(ResultDependsOnTypeRepr *T) {
return doIt(T->getBase());
}

bool Traversal::visitOpaqueReturnTypeRepr(OpaqueReturnTypeRepr *T) {
return doIt(T->getConstraint());
}
Expand Down
Loading