Skip to content

Commit d6d336e

Browse files
committed
[sil] Update all usages of old API SILValue::getOwnershipKind() in favor of new ValueBase::getOwnershipKind().
Andy some time ago already created the new API but didn't go through and update the old occurences. I did that in this PR and then deprecated the old API. The tree is clean, so I could just remove it, but I decided to be nicer to downstream people by deprecating it first.
1 parent 23e5143 commit d6d336e

File tree

73 files changed

+256
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+256
-256
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bool canOpcodeForwardGuaranteedValues(Operand *use);
5353
// This is the use-def equivalent of use->getOperandOwnership() ==
5454
// OperandOwnership::ForwardingBorrow.
5555
inline bool isForwardingBorrow(SILValue value) {
56-
assert(value.getOwnershipKind() == OwnershipKind::Guaranteed);
56+
assert(value->getOwnershipKind() == OwnershipKind::Guaranteed);
5757
return canOpcodeForwardGuaranteedValues(value);
5858
}
5959

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

@@ -445,7 +445,7 @@ class BorrowedValueKind {
445445

446446
public:
447447
static BorrowedValueKind get(SILValue value) {
448-
if (value.getOwnershipKind() != OwnershipKind::Guaranteed)
448+
if (value->getOwnershipKind() != OwnershipKind::Guaranteed)
449449
return Kind::Invalid;
450450
switch (value->getKind()) {
451451
default:
@@ -1025,7 +1025,7 @@ class OwnedValueIntroducerKind {
10251025

10261026
public:
10271027
static OwnedValueIntroducerKind get(SILValue value) {
1028-
if (value.getOwnershipKind() != OwnershipKind::Owned)
1028+
if (value->getOwnershipKind() != OwnershipKind::Owned)
10291029
return Kind::Invalid;
10301030

10311031
switch (value->getKind()) {

include/swift/SIL/SILBuilder.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -768,13 +768,13 @@ class SILBuilder {
768768

769769
SILValue emitBeginBorrowOperation(SILLocation loc, SILValue v) {
770770
if (!hasOwnership() ||
771-
v.getOwnershipKind().isCompatibleWith(OwnershipKind::Guaranteed))
771+
v->getOwnershipKind().isCompatibleWith(OwnershipKind::Guaranteed))
772772
return v;
773773
return createBeginBorrow(loc, v);
774774
}
775775

776776
void emitEndBorrowOperation(SILLocation loc, SILValue v) {
777-
if (!hasOwnership() || v.getOwnershipKind() == OwnershipKind::None)
777+
if (!hasOwnership() || v->getOwnershipKind() == OwnershipKind::None)
778778
return;
779779
createEndBorrow(loc, v);
780780
}
@@ -927,7 +927,7 @@ class SILBuilder {
927927
MarkUninitializedInst *
928928
createMarkUninitialized(SILLocation Loc, SILValue src,
929929
MarkUninitializedInst::Kind k) {
930-
return createMarkUninitialized(Loc, src, k, src.getOwnershipKind());
930+
return createMarkUninitialized(Loc, src, k, src->getOwnershipKind());
931931
}
932932

933933
MarkUninitializedInst *
@@ -1054,7 +1054,7 @@ class SILBuilder {
10541054
SILType Ty,
10551055
bool WithoutActuallyEscaping) {
10561056
return createConvertFunction(Loc, Op, Ty, WithoutActuallyEscaping,
1057-
Op.getOwnershipKind());
1057+
Op->getOwnershipKind());
10581058
}
10591059

10601060
ConvertFunctionInst *
@@ -1075,7 +1075,7 @@ class SILBuilder {
10751075
}
10761076

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

10811081
UpcastInst *createUpcast(SILLocation Loc, SILValue Op, SILType Ty,
@@ -1101,7 +1101,7 @@ class SILBuilder {
11011101
UncheckedRefCastInst *createUncheckedRefCast(SILLocation Loc, SILValue Op,
11021102
SILType Ty) {
11031103
return insert(UncheckedRefCastInst::create(
1104-
getSILDebugLocation(Loc), Op, Ty, getFunction(), Op.getOwnershipKind()));
1104+
getSILDebugLocation(Loc), Op, Ty, getFunction(), Op->getOwnershipKind()));
11051105
}
11061106

11071107
UncheckedRefCastInst *
@@ -1141,7 +1141,7 @@ class SILBuilder {
11411141

11421142
UncheckedValueCastInst *createUncheckedValueCast(SILLocation Loc, SILValue Op,
11431143
SILType Ty) {
1144-
return createUncheckedValueCast(Loc, Op, Ty, Op.getOwnershipKind());
1144+
return createUncheckedValueCast(Loc, Op, Ty, Op->getOwnershipKind());
11451145
}
11461146

11471147
UncheckedValueCastInst *
@@ -1155,7 +1155,7 @@ class SILBuilder {
11551155

11561156
RefToBridgeObjectInst *createRefToBridgeObject(SILLocation Loc, SILValue Ref,
11571157
SILValue Bits) {
1158-
return createRefToBridgeObject(Loc, Ref, Bits, Ref.getOwnershipKind());
1158+
return createRefToBridgeObject(Loc, Ref, Bits, Ref->getOwnershipKind());
11591159
}
11601160

11611161
RefToBridgeObjectInst *
@@ -1168,7 +1168,7 @@ class SILBuilder {
11681168

11691169
BridgeObjectToRefInst *createBridgeObjectToRef(SILLocation Loc, SILValue Op,
11701170
SILType Ty) {
1171-
return createBridgeObjectToRef(Loc, Op, Ty, Op.getOwnershipKind());
1171+
return createBridgeObjectToRef(Loc, Op, Ty, Op->getOwnershipKind());
11721172
}
11731173

11741174
BridgeObjectToRefInst *
@@ -1211,7 +1211,7 @@ class SILBuilder {
12111211

12121212
ThinToThickFunctionInst *createThinToThickFunction(SILLocation Loc,
12131213
SILValue Op, SILType Ty) {
1214-
return createThinToThickFunction(Loc, Op, Ty, Op.getOwnershipKind());
1214+
return createThinToThickFunction(Loc, Op, Ty, Op->getOwnershipKind());
12151215
}
12161216

12171217
ThinToThickFunctionInst *
@@ -1327,7 +1327,7 @@ class SILBuilder {
13271327
SILType destLoweredTy,
13281328
CanType destFormalTy) {
13291329
return createUnconditionalCheckedCast(Loc, op, destLoweredTy, destFormalTy,
1330-
op.getOwnershipKind());
1330+
op->getOwnershipKind());
13311331
}
13321332

13331333
UnconditionalCheckedCastInst *
@@ -1473,7 +1473,7 @@ class SILBuilder {
14731473
EnumInst *createEnum(SILLocation Loc, SILValue Operand,
14741474
EnumElementDecl *Element, SILType Ty) {
14751475
return createEnum(Loc, Operand, Element, Ty,
1476-
Operand ? Operand.getOwnershipKind()
1476+
Operand ? Operand->getOwnershipKind()
14771477
: ValueOwnershipKind(OwnershipKind::None));
14781478
}
14791479

@@ -1513,7 +1513,7 @@ class SILBuilder {
15131513
EnumElementDecl *Element,
15141514
SILType Ty) {
15151515
return createUncheckedEnumData(Loc, Operand, Element, Ty,
1516-
Operand.getOwnershipKind());
1516+
Operand->getOwnershipKind());
15171517
}
15181518

15191519
UncheckedEnumDataInst *createUncheckedEnumData(SILLocation Loc,
@@ -1570,7 +1570,7 @@ class SILBuilder {
15701570
ProfileCounter DefaultCount = ProfileCounter()) {
15711571
return createSelectEnum(Loc, Operand, Ty, DefaultValue, CaseValues,
15721572
CaseCounts, DefaultCount,
1573-
Operand.getOwnershipKind());
1573+
Operand->getOwnershipKind());
15741574
}
15751575

15761576
SelectEnumInst *createSelectEnum(
@@ -1605,14 +1605,14 @@ class SILBuilder {
16051605
TupleExtractInst *createTupleExtract(SILLocation Loc, SILValue Operand,
16061606
unsigned FieldNo, SILType ResultTy) {
16071607
return createTupleExtract(Loc, Operand, FieldNo, ResultTy,
1608-
Operand.getOwnershipKind());
1608+
Operand->getOwnershipKind());
16091609
}
16101610

16111611
TupleExtractInst *createTupleExtract(SILLocation Loc, SILValue Operand,
16121612
unsigned FieldNo) {
16131613
auto type = Operand->getType().getTupleElementType(FieldNo);
16141614
return createTupleExtract(Loc, Operand, FieldNo, type,
1615-
Operand.getOwnershipKind());
1615+
Operand->getOwnershipKind());
16161616
}
16171617

16181618
TupleExtractInst *
@@ -1642,15 +1642,15 @@ class SILBuilder {
16421642
StructExtractInst *createStructExtract(SILLocation Loc, SILValue Operand,
16431643
VarDecl *Field, SILType ResultTy) {
16441644
return createStructExtract(Loc, Operand, Field, ResultTy,
1645-
Operand.getOwnershipKind());
1645+
Operand->getOwnershipKind());
16461646
}
16471647

16481648
StructExtractInst *createStructExtract(SILLocation Loc, SILValue Operand,
16491649
VarDecl *Field) {
16501650
auto type = Operand->getType().getFieldType(Field, getModule(),
16511651
getTypeExpansionContext());
16521652
return createStructExtract(Loc, Operand, Field, type,
1653-
Operand.getOwnershipKind());
1653+
Operand->getOwnershipKind());
16541654
}
16551655

16561656
StructExtractInst *
@@ -1659,7 +1659,7 @@ class SILBuilder {
16591659
ValueOwnershipKind forwardingOwnershipKind) {
16601660
return insert(new (getModule()) StructExtractInst(
16611661
getSILDebugLocation(Loc), Operand, Field, ResultTy,
1662-
Operand.getOwnershipKind()));
1662+
Operand->getOwnershipKind()));
16631663
}
16641664

16651665
StructElementAddrInst *createStructElementAddr(SILLocation Loc,
@@ -1701,7 +1701,7 @@ class SILBuilder {
17011701
SILValue Operand) {
17021702
return insert(
17031703
DestructureStructInst::create(getFunction(), getSILDebugLocation(Loc),
1704-
Operand, Operand.getOwnershipKind()));
1704+
Operand, Operand->getOwnershipKind()));
17051705
}
17061706

17071707
DestructureStructInst *
@@ -1714,7 +1714,7 @@ class SILBuilder {
17141714

17151715
DestructureTupleInst *createDestructureTuple(SILLocation Loc,
17161716
SILValue Operand) {
1717-
return createDestructureTuple(Loc, Operand, Operand.getOwnershipKind());
1717+
return createDestructureTuple(Loc, Operand, Operand->getOwnershipKind());
17181718
}
17191719

17201720
DestructureTupleInst *
@@ -1793,7 +1793,7 @@ class SILBuilder {
17931793
SILValue Operand,
17941794
SILType SelfTy) {
17951795
return createOpenExistentialValue(Loc, Operand, SelfTy,
1796-
Operand.getOwnershipKind());
1796+
Operand->getOwnershipKind());
17971797
}
17981798

17991799
OpenExistentialValueInst *
@@ -1813,7 +1813,7 @@ class SILBuilder {
18131813
OpenExistentialRefInst *
18141814
createOpenExistentialRef(SILLocation Loc, SILValue Operand, SILType Ty) {
18151815
return createOpenExistentialRef(Loc, Operand, Ty,
1816-
Operand.getOwnershipKind());
1816+
Operand->getOwnershipKind());
18171817
}
18181818

18191819
OpenExistentialRefInst *
@@ -1832,7 +1832,7 @@ class SILBuilder {
18321832
OpenExistentialBoxValueInst *
18331833
createOpenExistentialBoxValue(SILLocation Loc, SILValue Operand, SILType Ty) {
18341834
return createOpenExistentialBoxValue(Loc, Operand, Ty,
1835-
Operand.getOwnershipKind());
1835+
Operand->getOwnershipKind());
18361836
}
18371837

18381838
OpenExistentialBoxValueInst *
@@ -1876,7 +1876,7 @@ class SILBuilder {
18761876
ArrayRef<ProtocolConformanceRef> Conformances) {
18771877
return createInitExistentialRef(Loc, ExistentialType, FormalConcreteType,
18781878
Concrete, Conformances,
1879-
Concrete.getOwnershipKind());
1879+
Concrete->getOwnershipKind());
18801880
}
18811881

18821882
InitExistentialRefInst *
@@ -2001,7 +2001,7 @@ class SILBuilder {
20012001

20022002
MarkDependenceInst *createMarkDependence(SILLocation Loc, SILValue value,
20032003
SILValue base) {
2004-
return createMarkDependence(Loc, value, base, value.getOwnershipKind());
2004+
return createMarkDependence(Loc, value, base, value->getOwnershipKind());
20052005
}
20062006

20072007
MarkDependenceInst *
@@ -2489,7 +2489,7 @@ class SILBuilder {
24892489
/// lowering for the non-address value.
24902490
void emitDestroyValueOperation(SILLocation Loc, SILValue v) {
24912491
assert(!v->getType().isAddress());
2492-
if (F->hasOwnership() && v.getOwnershipKind() == OwnershipKind::None)
2492+
if (F->hasOwnership() && v->getOwnershipKind() == OwnershipKind::None)
24932493
return;
24942494
auto &lowering = getTypeLowering(v->getType());
24952495
lowering.emitDestroyValue(*this, Loc, v);
@@ -2501,7 +2501,7 @@ class SILBuilder {
25012501
SILLocation Loc, SILValue v,
25022502
Lowering::TypeLowering::TypeExpansionKind expansionKind) {
25032503
assert(!v->getType().isAddress());
2504-
if (F->hasOwnership() && v.getOwnershipKind() == OwnershipKind::None)
2504+
if (F->hasOwnership() && v->getOwnershipKind() == OwnershipKind::None)
25052505
return;
25062506
auto &lowering = getTypeLowering(v->getType());
25072507
lowering.emitLoweredDestroyValue(*this, Loc, v, expansionKind);
@@ -2523,7 +2523,7 @@ class SILBuilder {
25232523
assert(!v->getType().isAddress());
25242524
if (v->getType().isTrivial(*getInsertionBB()->getParent()))
25252525
return v;
2526-
assert(v.getOwnershipKind() == OwnershipKind::Owned &&
2526+
assert(v->getOwnershipKind() == OwnershipKind::Owned &&
25272527
"move_value consumes its argument");
25282528
return createMoveValue(Loc, v);
25292529
}
@@ -2626,7 +2626,7 @@ class SILBuilder {
26262626
SILLocation Loc, NormalDifferentiableFunctionTypeComponent Extractee,
26272627
SILValue Function, Optional<SILType> ExtracteeType = None) {
26282628
return createDifferentiableFunctionExtract(
2629-
Loc, Extractee, Function, Function.getOwnershipKind(), ExtracteeType);
2629+
Loc, Extractee, Function, Function->getOwnershipKind(), ExtracteeType);
26302630
}
26312631

26322632
DifferentiableFunctionExtractInst *createDifferentiableFunctionExtract(
@@ -2649,7 +2649,7 @@ class SILBuilder {
26492649
SILLocation Loc, LinearDifferentiableFunctionTypeComponent Extractee,
26502650
SILValue Function) {
26512651
return createLinearFunctionExtract(Loc, Extractee, Function,
2652-
Function.getOwnershipKind());
2652+
Function->getOwnershipKind());
26532653
}
26542654

26552655
LinearFunctionExtractInst *createLinearFunctionExtract(

include/swift/SIL/SILCloner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,8 +2456,8 @@ void SILCloner<ImplClass>::visitUncheckedOwnershipConversionInst(
24562456
return recordFoldedValue(Inst, getOpValue(Inst->getOperand()));
24572457
}
24582458

2459-
ValueOwnershipKind Kind = SILValue(Inst).getOwnershipKind();
2460-
if (getOpValue(Inst->getOperand()).getOwnershipKind() ==
2459+
ValueOwnershipKind Kind = SILValue(Inst)->getOwnershipKind();
2460+
if (getOpValue(Inst->getOperand())->getOwnershipKind() ==
24612461
OwnershipKind::None) {
24622462
Kind = OwnershipKind::None;
24632463
}

include/swift/SIL/SILValue.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ struct ValueOwnershipKind {
320320
return bool(merge(other));
321321
}
322322

323-
/// Returns isCompatibleWith(other.getOwnershipKind()).
323+
/// Returns isCompatibleWith(other->getOwnershipKind()).
324324
///
325325
/// Definition is inline after SILValue is defined to work around circular
326326
/// dependencies.
@@ -668,9 +668,9 @@ class SILValue {
668668
/// NOTE: This is implemented in ValueOwnership.cpp not SILValue.cpp.
669669
///
670670
/// FIXME: remove this redundant API from SILValue.
671-
ValueOwnershipKind getOwnershipKind() const {
671+
LLVM_ATTRIBUTE_DEPRECATED(ValueOwnershipKind getOwnershipKind() const {
672672
return Value->getOwnershipKind();
673-
}
673+
}, "Please use ValueBase::getOwnershipKind()");
674674

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

684684
inline bool ValueOwnershipKind::isCompatibleWith(SILValue other) const {
685-
return isCompatibleWith(other.getOwnershipKind());
685+
return isCompatibleWith(other->getOwnershipKind());
686686
}
687687

688688
/// Constraints on the ownership of an operand value.

include/swift/SILOptimizer/Utils/CanonicalOSSALifetime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class CanonicalizeOSSALifetime {
234234
static SILValue getCanonicalCopiedDef(SILValue v) {
235235
while (auto *copy = dyn_cast<CopyValueInst>(v)) {
236236
auto def = copy->getOperand();
237-
if (def.getOwnershipKind() != OwnershipKind::Owned) {
237+
if (def->getOwnershipKind() != OwnershipKind::Owned) {
238238
// This guaranteed value cannot be handled, treat the copy as an owned
239239
// live range def instead.
240240
return copy;

include/swift/SILOptimizer/Utils/OwnershipOptUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ namespace swift {
3131
/// Returns true if this value requires OSSA cleanups.
3232
inline bool requiresOSSACleanup(SILValue v) {
3333
return v->getFunction()->hasOwnership()
34-
&& v.getOwnershipKind() != OwnershipKind::None
35-
&& v.getOwnershipKind() != OwnershipKind::Unowned;
34+
&& v->getOwnershipKind() != OwnershipKind::None
35+
&& v->getOwnershipKind() != OwnershipKind::Unowned;
3636
}
3737

3838
/// Rewrite the lifetime of \p ownedValue to match \p lifetimeBoundary. This may

include/swift/SILOptimizer/Utils/ScopeOptUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class SILOptScope : public SILOptScopeBase {
269269
/// returned since end_borrows should not be cancellable.
270270
ScopedValue borrowValue(SILInstruction *insertPt, SILValue value) {
271271
if (!insertPt->getFunction()->hasOwnership() ||
272-
value.getOwnershipKind().isCompatibleWith(OwnershipKind::Guaranteed))
272+
value->getOwnershipKind().isCompatibleWith(OwnershipKind::Guaranteed))
273273
return {};
274274
SILValue borrow = SILBuilderWithScope(insertPt).emitBeginBorrowOperation(
275275
insertPt->getLoc(), value);

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class OperandOwnershipClassifier
5959
SILValue getValue() const { return op.get(); }
6060

6161
ValueOwnershipKind getOwnershipKind() const {
62-
return op.get().getOwnershipKind();
62+
return op.get()->getOwnershipKind();
6363
}
6464

6565
unsigned getOperandIndex() const { return op.getOperandNumber(); }

0 commit comments

Comments
 (0)