Skip to content

[sil] Update all usages of old API SILValue::getOwnershipKind() in favor of new ValueBase::getOwnershipKind(). #60227

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
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
8 changes: 4 additions & 4 deletions include/swift/SIL/OwnershipUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool canOpcodeForwardGuaranteedValues(Operand *use);
// This is the use-def equivalent of use->getOperandOwnership() ==
// OperandOwnership::ForwardingBorrow.
inline bool isForwardingBorrow(SILValue value) {
assert(value.getOwnershipKind() == OwnershipKind::Guaranteed);
assert(value->getOwnershipKind() == OwnershipKind::Guaranteed);
return canOpcodeForwardGuaranteedValues(value);
}

Expand All @@ -74,7 +74,7 @@ bool canOpcodeForwardOwnedValues(Operand *use);
// This is the use-def equivalent of use->getOperandOwnership() ==
// OperandOwnership::ForwardingConsume.
inline bool isForwardingConsume(SILValue value) {
assert(value.getOwnershipKind() == OwnershipKind::Owned);
assert(value->getOwnershipKind() == OwnershipKind::Owned);
return canOpcodeForwardOwnedValues(value);
}

Expand Down Expand Up @@ -445,7 +445,7 @@ class BorrowedValueKind {

public:
static BorrowedValueKind get(SILValue value) {
if (value.getOwnershipKind() != OwnershipKind::Guaranteed)
if (value->getOwnershipKind() != OwnershipKind::Guaranteed)
return Kind::Invalid;
switch (value->getKind()) {
default:
Expand Down Expand Up @@ -1025,7 +1025,7 @@ class OwnedValueIntroducerKind {

public:
static OwnedValueIntroducerKind get(SILValue value) {
if (value.getOwnershipKind() != OwnershipKind::Owned)
if (value->getOwnershipKind() != OwnershipKind::Owned)
return Kind::Invalid;

switch (value->getKind()) {
Expand Down
65 changes: 33 additions & 32 deletions include/swift/SIL/SILBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,13 @@ class SILBuilder {

SILValue emitBeginBorrowOperation(SILLocation loc, SILValue v) {
if (!hasOwnership() ||
v.getOwnershipKind().isCompatibleWith(OwnershipKind::Guaranteed))
v->getOwnershipKind().isCompatibleWith(OwnershipKind::Guaranteed))
return v;
return createBeginBorrow(loc, v);
}

void emitEndBorrowOperation(SILLocation loc, SILValue v) {
if (!hasOwnership() || v.getOwnershipKind() == OwnershipKind::None)
if (!hasOwnership() || v->getOwnershipKind() == OwnershipKind::None)
return;
createEndBorrow(loc, v);
}
Expand Down Expand Up @@ -927,7 +927,7 @@ class SILBuilder {
MarkUninitializedInst *
createMarkUninitialized(SILLocation Loc, SILValue src,
MarkUninitializedInst::Kind k) {
return createMarkUninitialized(Loc, src, k, src.getOwnershipKind());
return createMarkUninitialized(Loc, src, k, src->getOwnershipKind());
}

MarkUninitializedInst *
Expand Down Expand Up @@ -1054,7 +1054,7 @@ class SILBuilder {
SILType Ty,
bool WithoutActuallyEscaping) {
return createConvertFunction(Loc, Op, Ty, WithoutActuallyEscaping,
Op.getOwnershipKind());
Op->getOwnershipKind());
}

ConvertFunctionInst *
Expand All @@ -1075,7 +1075,7 @@ class SILBuilder {
}

UpcastInst *createUpcast(SILLocation Loc, SILValue Op, SILType Ty) {
return createUpcast(Loc, Op, Ty, Op.getOwnershipKind());
return createUpcast(Loc, Op, Ty, Op->getOwnershipKind());
}

UpcastInst *createUpcast(SILLocation Loc, SILValue Op, SILType Ty,
Expand All @@ -1100,8 +1100,9 @@ class SILBuilder {

UncheckedRefCastInst *createUncheckedRefCast(SILLocation Loc, SILValue Op,
SILType Ty) {
return insert(UncheckedRefCastInst::create(
getSILDebugLocation(Loc), Op, Ty, getFunction(), Op.getOwnershipKind()));
return insert(UncheckedRefCastInst::create(getSILDebugLocation(Loc), Op, Ty,
getFunction(),
Op->getOwnershipKind()));
}

UncheckedRefCastInst *
Expand Down Expand Up @@ -1141,7 +1142,7 @@ class SILBuilder {

UncheckedValueCastInst *createUncheckedValueCast(SILLocation Loc, SILValue Op,
SILType Ty) {
return createUncheckedValueCast(Loc, Op, Ty, Op.getOwnershipKind());
return createUncheckedValueCast(Loc, Op, Ty, Op->getOwnershipKind());
}

UncheckedValueCastInst *
Expand All @@ -1155,7 +1156,7 @@ class SILBuilder {

RefToBridgeObjectInst *createRefToBridgeObject(SILLocation Loc, SILValue Ref,
SILValue Bits) {
return createRefToBridgeObject(Loc, Ref, Bits, Ref.getOwnershipKind());
return createRefToBridgeObject(Loc, Ref, Bits, Ref->getOwnershipKind());
}

RefToBridgeObjectInst *
Expand All @@ -1168,7 +1169,7 @@ class SILBuilder {

BridgeObjectToRefInst *createBridgeObjectToRef(SILLocation Loc, SILValue Op,
SILType Ty) {
return createBridgeObjectToRef(Loc, Op, Ty, Op.getOwnershipKind());
return createBridgeObjectToRef(Loc, Op, Ty, Op->getOwnershipKind());
}

BridgeObjectToRefInst *
Expand Down Expand Up @@ -1211,7 +1212,7 @@ class SILBuilder {

ThinToThickFunctionInst *createThinToThickFunction(SILLocation Loc,
SILValue Op, SILType Ty) {
return createThinToThickFunction(Loc, Op, Ty, Op.getOwnershipKind());
return createThinToThickFunction(Loc, Op, Ty, Op->getOwnershipKind());
}

ThinToThickFunctionInst *
Expand Down Expand Up @@ -1327,7 +1328,7 @@ class SILBuilder {
SILType destLoweredTy,
CanType destFormalTy) {
return createUnconditionalCheckedCast(Loc, op, destLoweredTy, destFormalTy,
op.getOwnershipKind());
op->getOwnershipKind());
}

UnconditionalCheckedCastInst *
Expand Down Expand Up @@ -1473,7 +1474,7 @@ class SILBuilder {
EnumInst *createEnum(SILLocation Loc, SILValue Operand,
EnumElementDecl *Element, SILType Ty) {
return createEnum(Loc, Operand, Element, Ty,
Operand ? Operand.getOwnershipKind()
Operand ? Operand->getOwnershipKind()
: ValueOwnershipKind(OwnershipKind::None));
}

Expand Down Expand Up @@ -1513,7 +1514,7 @@ class SILBuilder {
EnumElementDecl *Element,
SILType Ty) {
return createUncheckedEnumData(Loc, Operand, Element, Ty,
Operand.getOwnershipKind());
Operand->getOwnershipKind());
}

UncheckedEnumDataInst *createUncheckedEnumData(SILLocation Loc,
Expand Down Expand Up @@ -1570,7 +1571,7 @@ class SILBuilder {
ProfileCounter DefaultCount = ProfileCounter()) {
return createSelectEnum(Loc, Operand, Ty, DefaultValue, CaseValues,
CaseCounts, DefaultCount,
Operand.getOwnershipKind());
Operand->getOwnershipKind());
}

SelectEnumInst *createSelectEnum(
Expand Down Expand Up @@ -1605,14 +1606,14 @@ class SILBuilder {
TupleExtractInst *createTupleExtract(SILLocation Loc, SILValue Operand,
unsigned FieldNo, SILType ResultTy) {
return createTupleExtract(Loc, Operand, FieldNo, ResultTy,
Operand.getOwnershipKind());
Operand->getOwnershipKind());
}

TupleExtractInst *createTupleExtract(SILLocation Loc, SILValue Operand,
unsigned FieldNo) {
auto type = Operand->getType().getTupleElementType(FieldNo);
return createTupleExtract(Loc, Operand, FieldNo, type,
Operand.getOwnershipKind());
Operand->getOwnershipKind());
}

TupleExtractInst *
Expand Down Expand Up @@ -1642,15 +1643,15 @@ class SILBuilder {
StructExtractInst *createStructExtract(SILLocation Loc, SILValue Operand,
VarDecl *Field, SILType ResultTy) {
return createStructExtract(Loc, Operand, Field, ResultTy,
Operand.getOwnershipKind());
Operand->getOwnershipKind());
}

StructExtractInst *createStructExtract(SILLocation Loc, SILValue Operand,
VarDecl *Field) {
auto type = Operand->getType().getFieldType(Field, getModule(),
getTypeExpansionContext());
return createStructExtract(Loc, Operand, Field, type,
Operand.getOwnershipKind());
Operand->getOwnershipKind());
}

StructExtractInst *
Expand All @@ -1659,7 +1660,7 @@ class SILBuilder {
ValueOwnershipKind forwardingOwnershipKind) {
return insert(new (getModule()) StructExtractInst(
getSILDebugLocation(Loc), Operand, Field, ResultTy,
Operand.getOwnershipKind()));
Operand->getOwnershipKind()));
}

StructElementAddrInst *createStructElementAddr(SILLocation Loc,
Expand Down Expand Up @@ -1701,7 +1702,7 @@ class SILBuilder {
SILValue Operand) {
return insert(
DestructureStructInst::create(getFunction(), getSILDebugLocation(Loc),
Operand, Operand.getOwnershipKind()));
Operand, Operand->getOwnershipKind()));
}

DestructureStructInst *
Expand All @@ -1714,7 +1715,7 @@ class SILBuilder {

DestructureTupleInst *createDestructureTuple(SILLocation Loc,
SILValue Operand) {
return createDestructureTuple(Loc, Operand, Operand.getOwnershipKind());
return createDestructureTuple(Loc, Operand, Operand->getOwnershipKind());
}

DestructureTupleInst *
Expand Down Expand Up @@ -1793,7 +1794,7 @@ class SILBuilder {
SILValue Operand,
SILType SelfTy) {
return createOpenExistentialValue(Loc, Operand, SelfTy,
Operand.getOwnershipKind());
Operand->getOwnershipKind());
}

OpenExistentialValueInst *
Expand All @@ -1813,7 +1814,7 @@ class SILBuilder {
OpenExistentialRefInst *
createOpenExistentialRef(SILLocation Loc, SILValue Operand, SILType Ty) {
return createOpenExistentialRef(Loc, Operand, Ty,
Operand.getOwnershipKind());
Operand->getOwnershipKind());
}

OpenExistentialRefInst *
Expand All @@ -1832,7 +1833,7 @@ class SILBuilder {
OpenExistentialBoxValueInst *
createOpenExistentialBoxValue(SILLocation Loc, SILValue Operand, SILType Ty) {
return createOpenExistentialBoxValue(Loc, Operand, Ty,
Operand.getOwnershipKind());
Operand->getOwnershipKind());
}

OpenExistentialBoxValueInst *
Expand Down Expand Up @@ -1876,7 +1877,7 @@ class SILBuilder {
ArrayRef<ProtocolConformanceRef> Conformances) {
return createInitExistentialRef(Loc, ExistentialType, FormalConcreteType,
Concrete, Conformances,
Concrete.getOwnershipKind());
Concrete->getOwnershipKind());
}

InitExistentialRefInst *
Expand Down Expand Up @@ -2001,7 +2002,7 @@ class SILBuilder {

MarkDependenceInst *createMarkDependence(SILLocation Loc, SILValue value,
SILValue base) {
return createMarkDependence(Loc, value, base, value.getOwnershipKind());
return createMarkDependence(Loc, value, base, value->getOwnershipKind());
}

MarkDependenceInst *
Expand Down Expand Up @@ -2489,7 +2490,7 @@ class SILBuilder {
/// lowering for the non-address value.
void emitDestroyValueOperation(SILLocation Loc, SILValue v) {
assert(!v->getType().isAddress());
if (F->hasOwnership() && v.getOwnershipKind() == OwnershipKind::None)
if (F->hasOwnership() && v->getOwnershipKind() == OwnershipKind::None)
return;
auto &lowering = getTypeLowering(v->getType());
lowering.emitDestroyValue(*this, Loc, v);
Expand All @@ -2501,7 +2502,7 @@ class SILBuilder {
SILLocation Loc, SILValue v,
Lowering::TypeLowering::TypeExpansionKind expansionKind) {
assert(!v->getType().isAddress());
if (F->hasOwnership() && v.getOwnershipKind() == OwnershipKind::None)
if (F->hasOwnership() && v->getOwnershipKind() == OwnershipKind::None)
return;
auto &lowering = getTypeLowering(v->getType());
lowering.emitLoweredDestroyValue(*this, Loc, v, expansionKind);
Expand All @@ -2523,7 +2524,7 @@ class SILBuilder {
assert(!v->getType().isAddress());
if (v->getType().isTrivial(*getInsertionBB()->getParent()))
return v;
assert(v.getOwnershipKind() == OwnershipKind::Owned &&
assert(v->getOwnershipKind() == OwnershipKind::Owned &&
"move_value consumes its argument");
return createMoveValue(Loc, v);
}
Expand Down Expand Up @@ -2626,7 +2627,7 @@ class SILBuilder {
SILLocation Loc, NormalDifferentiableFunctionTypeComponent Extractee,
SILValue Function, Optional<SILType> ExtracteeType = None) {
return createDifferentiableFunctionExtract(
Loc, Extractee, Function, Function.getOwnershipKind(), ExtracteeType);
Loc, Extractee, Function, Function->getOwnershipKind(), ExtracteeType);
}

DifferentiableFunctionExtractInst *createDifferentiableFunctionExtract(
Expand All @@ -2649,7 +2650,7 @@ class SILBuilder {
SILLocation Loc, LinearDifferentiableFunctionTypeComponent Extractee,
SILValue Function) {
return createLinearFunctionExtract(Loc, Extractee, Function,
Function.getOwnershipKind());
Function->getOwnershipKind());
}

LinearFunctionExtractInst *createLinearFunctionExtract(
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -2456,8 +2456,8 @@ void SILCloner<ImplClass>::visitUncheckedOwnershipConversionInst(
return recordFoldedValue(Inst, getOpValue(Inst->getOperand()));
}

ValueOwnershipKind Kind = SILValue(Inst).getOwnershipKind();
if (getOpValue(Inst->getOperand()).getOwnershipKind() ==
ValueOwnershipKind Kind = SILValue(Inst)->getOwnershipKind();
if (getOpValue(Inst->getOperand())->getOwnershipKind() ==
OwnershipKind::None) {
Kind = OwnershipKind::None;
}
Expand Down
11 changes: 6 additions & 5 deletions include/swift/SIL/SILValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ struct ValueOwnershipKind {
return bool(merge(other));
}

/// Returns isCompatibleWith(other.getOwnershipKind()).
/// Returns isCompatibleWith(other->getOwnershipKind()).
///
/// Definition is inline after SILValue is defined to work around circular
/// dependencies.
Expand Down Expand Up @@ -668,9 +668,10 @@ class SILValue {
/// NOTE: This is implemented in ValueOwnership.cpp not SILValue.cpp.
///
/// FIXME: remove this redundant API from SILValue.
ValueOwnershipKind getOwnershipKind() const {
return Value->getOwnershipKind();
}
LLVM_ATTRIBUTE_DEPRECATED(
ValueOwnershipKind getOwnershipKind()
const { return Value->getOwnershipKind(); },
"Please use ValueBase::getOwnershipKind()");

/// Verify that this SILValue and its uses respects ownership invariants.
void verifyOwnership(DeadEndBlocks *DEBlocks) const;
Expand All @@ -682,7 +683,7 @@ class SILValue {
inline SILNodePointer::SILNodePointer(SILValue value) : node(value) { }

inline bool ValueOwnershipKind::isCompatibleWith(SILValue other) const {
return isCompatibleWith(other.getOwnershipKind());
return isCompatibleWith(other->getOwnershipKind());
}

/// Constraints on the ownership of an operand value.
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SILOptimizer/Utils/CanonicalOSSALifetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class CanonicalizeOSSALifetime {
static SILValue getCanonicalCopiedDef(SILValue v) {
while (auto *copy = dyn_cast<CopyValueInst>(v)) {
auto def = copy->getOperand();
if (def.getOwnershipKind() != OwnershipKind::Owned) {
if (def->getOwnershipKind() != OwnershipKind::Owned) {
// This guaranteed value cannot be handled, treat the copy as an owned
// live range def instead.
return copy;
Expand Down
6 changes: 3 additions & 3 deletions include/swift/SILOptimizer/Utils/OwnershipOptUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ namespace swift {

/// Returns true if this value requires OSSA cleanups.
inline bool requiresOSSACleanup(SILValue v) {
return v->getFunction()->hasOwnership()
&& v.getOwnershipKind() != OwnershipKind::None
&& v.getOwnershipKind() != OwnershipKind::Unowned;
return v->getFunction()->hasOwnership() &&
v->getOwnershipKind() != OwnershipKind::None &&
v->getOwnershipKind() != OwnershipKind::Unowned;
}

/// Rewrite the lifetime of \p ownedValue to match \p lifetimeBoundary. This may
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SILOptimizer/Utils/ScopeOptUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class SILOptScope : public SILOptScopeBase {
/// returned since end_borrows should not be cancellable.
ScopedValue borrowValue(SILInstruction *insertPt, SILValue value) {
if (!insertPt->getFunction()->hasOwnership() ||
value.getOwnershipKind().isCompatibleWith(OwnershipKind::Guaranteed))
value->getOwnershipKind().isCompatibleWith(OwnershipKind::Guaranteed))
return {};
SILValue borrow = SILBuilderWithScope(insertPt).emitBeginBorrowOperation(
insertPt->getLoc(), value);
Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/IR/OperandOwnership.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class OperandOwnershipClassifier
SILValue getValue() const { return op.get(); }

ValueOwnershipKind getOwnershipKind() const {
return op.get().getOwnershipKind();
return op.get()->getOwnershipKind();
}

unsigned getOperandIndex() const { return op.getOperandNumber(); }
Expand Down
Loading