Skip to content

Commit 595f9ec

Browse files
authored
Merge pull request #60227 from gottesmm/pr-7cd0c52b4594a9f652c787398bc3b4196252bd86
[sil] Update all usages of old API SILValue::getOwnershipKind() in favor of new ValueBase::getOwnershipKind().
2 parents 6f87d02 + 1e6187c commit 595f9ec

File tree

72 files changed

+272
-269
lines changed

Some content is hidden

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

72 files changed

+272
-269
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: 33 additions & 32 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,
@@ -1100,8 +1100,9 @@ class SILBuilder {
11001100

11011101
UncheckedRefCastInst *createUncheckedRefCast(SILLocation Loc, SILValue Op,
11021102
SILType Ty) {
1103-
return insert(UncheckedRefCastInst::create(
1104-
getSILDebugLocation(Loc), Op, Ty, getFunction(), Op.getOwnershipKind()));
1103+
return insert(UncheckedRefCastInst::create(getSILDebugLocation(Loc), Op, Ty,
1104+
getFunction(),
1105+
Op->getOwnershipKind()));
11051106
}
11061107

11071108
UncheckedRefCastInst *
@@ -1141,7 +1142,7 @@ class SILBuilder {
11411142

11421143
UncheckedValueCastInst *createUncheckedValueCast(SILLocation Loc, SILValue Op,
11431144
SILType Ty) {
1144-
return createUncheckedValueCast(Loc, Op, Ty, Op.getOwnershipKind());
1145+
return createUncheckedValueCast(Loc, Op, Ty, Op->getOwnershipKind());
11451146
}
11461147

11471148
UncheckedValueCastInst *
@@ -1155,7 +1156,7 @@ class SILBuilder {
11551156

11561157
RefToBridgeObjectInst *createRefToBridgeObject(SILLocation Loc, SILValue Ref,
11571158
SILValue Bits) {
1158-
return createRefToBridgeObject(Loc, Ref, Bits, Ref.getOwnershipKind());
1159+
return createRefToBridgeObject(Loc, Ref, Bits, Ref->getOwnershipKind());
11591160
}
11601161

11611162
RefToBridgeObjectInst *
@@ -1168,7 +1169,7 @@ class SILBuilder {
11681169

11691170
BridgeObjectToRefInst *createBridgeObjectToRef(SILLocation Loc, SILValue Op,
11701171
SILType Ty) {
1171-
return createBridgeObjectToRef(Loc, Op, Ty, Op.getOwnershipKind());
1172+
return createBridgeObjectToRef(Loc, Op, Ty, Op->getOwnershipKind());
11721173
}
11731174

11741175
BridgeObjectToRefInst *
@@ -1211,7 +1212,7 @@ class SILBuilder {
12111212

12121213
ThinToThickFunctionInst *createThinToThickFunction(SILLocation Loc,
12131214
SILValue Op, SILType Ty) {
1214-
return createThinToThickFunction(Loc, Op, Ty, Op.getOwnershipKind());
1215+
return createThinToThickFunction(Loc, Op, Ty, Op->getOwnershipKind());
12151216
}
12161217

12171218
ThinToThickFunctionInst *
@@ -1327,7 +1328,7 @@ class SILBuilder {
13271328
SILType destLoweredTy,
13281329
CanType destFormalTy) {
13291330
return createUnconditionalCheckedCast(Loc, op, destLoweredTy, destFormalTy,
1330-
op.getOwnershipKind());
1331+
op->getOwnershipKind());
13311332
}
13321333

13331334
UnconditionalCheckedCastInst *
@@ -1473,7 +1474,7 @@ class SILBuilder {
14731474
EnumInst *createEnum(SILLocation Loc, SILValue Operand,
14741475
EnumElementDecl *Element, SILType Ty) {
14751476
return createEnum(Loc, Operand, Element, Ty,
1476-
Operand ? Operand.getOwnershipKind()
1477+
Operand ? Operand->getOwnershipKind()
14771478
: ValueOwnershipKind(OwnershipKind::None));
14781479
}
14791480

@@ -1513,7 +1514,7 @@ class SILBuilder {
15131514
EnumElementDecl *Element,
15141515
SILType Ty) {
15151516
return createUncheckedEnumData(Loc, Operand, Element, Ty,
1516-
Operand.getOwnershipKind());
1517+
Operand->getOwnershipKind());
15171518
}
15181519

15191520
UncheckedEnumDataInst *createUncheckedEnumData(SILLocation Loc,
@@ -1570,7 +1571,7 @@ class SILBuilder {
15701571
ProfileCounter DefaultCount = ProfileCounter()) {
15711572
return createSelectEnum(Loc, Operand, Ty, DefaultValue, CaseValues,
15721573
CaseCounts, DefaultCount,
1573-
Operand.getOwnershipKind());
1574+
Operand->getOwnershipKind());
15741575
}
15751576

15761577
SelectEnumInst *createSelectEnum(
@@ -1605,14 +1606,14 @@ class SILBuilder {
16051606
TupleExtractInst *createTupleExtract(SILLocation Loc, SILValue Operand,
16061607
unsigned FieldNo, SILType ResultTy) {
16071608
return createTupleExtract(Loc, Operand, FieldNo, ResultTy,
1608-
Operand.getOwnershipKind());
1609+
Operand->getOwnershipKind());
16091610
}
16101611

16111612
TupleExtractInst *createTupleExtract(SILLocation Loc, SILValue Operand,
16121613
unsigned FieldNo) {
16131614
auto type = Operand->getType().getTupleElementType(FieldNo);
16141615
return createTupleExtract(Loc, Operand, FieldNo, type,
1615-
Operand.getOwnershipKind());
1616+
Operand->getOwnershipKind());
16161617
}
16171618

16181619
TupleExtractInst *
@@ -1642,15 +1643,15 @@ class SILBuilder {
16421643
StructExtractInst *createStructExtract(SILLocation Loc, SILValue Operand,
16431644
VarDecl *Field, SILType ResultTy) {
16441645
return createStructExtract(Loc, Operand, Field, ResultTy,
1645-
Operand.getOwnershipKind());
1646+
Operand->getOwnershipKind());
16461647
}
16471648

16481649
StructExtractInst *createStructExtract(SILLocation Loc, SILValue Operand,
16491650
VarDecl *Field) {
16501651
auto type = Operand->getType().getFieldType(Field, getModule(),
16511652
getTypeExpansionContext());
16521653
return createStructExtract(Loc, Operand, Field, type,
1653-
Operand.getOwnershipKind());
1654+
Operand->getOwnershipKind());
16541655
}
16551656

16561657
StructExtractInst *
@@ -1659,7 +1660,7 @@ class SILBuilder {
16591660
ValueOwnershipKind forwardingOwnershipKind) {
16601661
return insert(new (getModule()) StructExtractInst(
16611662
getSILDebugLocation(Loc), Operand, Field, ResultTy,
1662-
Operand.getOwnershipKind()));
1663+
Operand->getOwnershipKind()));
16631664
}
16641665

16651666
StructElementAddrInst *createStructElementAddr(SILLocation Loc,
@@ -1701,7 +1702,7 @@ class SILBuilder {
17011702
SILValue Operand) {
17021703
return insert(
17031704
DestructureStructInst::create(getFunction(), getSILDebugLocation(Loc),
1704-
Operand, Operand.getOwnershipKind()));
1705+
Operand, Operand->getOwnershipKind()));
17051706
}
17061707

17071708
DestructureStructInst *
@@ -1714,7 +1715,7 @@ class SILBuilder {
17141715

17151716
DestructureTupleInst *createDestructureTuple(SILLocation Loc,
17161717
SILValue Operand) {
1717-
return createDestructureTuple(Loc, Operand, Operand.getOwnershipKind());
1718+
return createDestructureTuple(Loc, Operand, Operand->getOwnershipKind());
17181719
}
17191720

17201721
DestructureTupleInst *
@@ -1793,7 +1794,7 @@ class SILBuilder {
17931794
SILValue Operand,
17941795
SILType SelfTy) {
17951796
return createOpenExistentialValue(Loc, Operand, SelfTy,
1796-
Operand.getOwnershipKind());
1797+
Operand->getOwnershipKind());
17971798
}
17981799

17991800
OpenExistentialValueInst *
@@ -1813,7 +1814,7 @@ class SILBuilder {
18131814
OpenExistentialRefInst *
18141815
createOpenExistentialRef(SILLocation Loc, SILValue Operand, SILType Ty) {
18151816
return createOpenExistentialRef(Loc, Operand, Ty,
1816-
Operand.getOwnershipKind());
1817+
Operand->getOwnershipKind());
18171818
}
18181819

18191820
OpenExistentialRefInst *
@@ -1832,7 +1833,7 @@ class SILBuilder {
18321833
OpenExistentialBoxValueInst *
18331834
createOpenExistentialBoxValue(SILLocation Loc, SILValue Operand, SILType Ty) {
18341835
return createOpenExistentialBoxValue(Loc, Operand, Ty,
1835-
Operand.getOwnershipKind());
1836+
Operand->getOwnershipKind());
18361837
}
18371838

18381839
OpenExistentialBoxValueInst *
@@ -1876,7 +1877,7 @@ class SILBuilder {
18761877
ArrayRef<ProtocolConformanceRef> Conformances) {
18771878
return createInitExistentialRef(Loc, ExistentialType, FormalConcreteType,
18781879
Concrete, Conformances,
1879-
Concrete.getOwnershipKind());
1880+
Concrete->getOwnershipKind());
18801881
}
18811882

18821883
InitExistentialRefInst *
@@ -2001,7 +2002,7 @@ class SILBuilder {
20012002

20022003
MarkDependenceInst *createMarkDependence(SILLocation Loc, SILValue value,
20032004
SILValue base) {
2004-
return createMarkDependence(Loc, value, base, value.getOwnershipKind());
2005+
return createMarkDependence(Loc, value, base, value->getOwnershipKind());
20052006
}
20062007

20072008
MarkDependenceInst *
@@ -2489,7 +2490,7 @@ class SILBuilder {
24892490
/// lowering for the non-address value.
24902491
void emitDestroyValueOperation(SILLocation Loc, SILValue v) {
24912492
assert(!v->getType().isAddress());
2492-
if (F->hasOwnership() && v.getOwnershipKind() == OwnershipKind::None)
2493+
if (F->hasOwnership() && v->getOwnershipKind() == OwnershipKind::None)
24932494
return;
24942495
auto &lowering = getTypeLowering(v->getType());
24952496
lowering.emitDestroyValue(*this, Loc, v);
@@ -2501,7 +2502,7 @@ class SILBuilder {
25012502
SILLocation Loc, SILValue v,
25022503
Lowering::TypeLowering::TypeExpansionKind expansionKind) {
25032504
assert(!v->getType().isAddress());
2504-
if (F->hasOwnership() && v.getOwnershipKind() == OwnershipKind::None)
2505+
if (F->hasOwnership() && v->getOwnershipKind() == OwnershipKind::None)
25052506
return;
25062507
auto &lowering = getTypeLowering(v->getType());
25072508
lowering.emitLoweredDestroyValue(*this, Loc, v, expansionKind);
@@ -2523,7 +2524,7 @@ class SILBuilder {
25232524
assert(!v->getType().isAddress());
25242525
if (v->getType().isTrivial(*getInsertionBB()->getParent()))
25252526
return v;
2526-
assert(v.getOwnershipKind() == OwnershipKind::Owned &&
2527+
assert(v->getOwnershipKind() == OwnershipKind::Owned &&
25272528
"move_value consumes its argument");
25282529
return createMoveValue(Loc, v);
25292530
}
@@ -2626,7 +2627,7 @@ class SILBuilder {
26262627
SILLocation Loc, NormalDifferentiableFunctionTypeComponent Extractee,
26272628
SILValue Function, Optional<SILType> ExtracteeType = None) {
26282629
return createDifferentiableFunctionExtract(
2629-
Loc, Extractee, Function, Function.getOwnershipKind(), ExtracteeType);
2630+
Loc, Extractee, Function, Function->getOwnershipKind(), ExtracteeType);
26302631
}
26312632

26322633
DifferentiableFunctionExtractInst *createDifferentiableFunctionExtract(
@@ -2649,7 +2650,7 @@ class SILBuilder {
26492650
SILLocation Loc, LinearDifferentiableFunctionTypeComponent Extractee,
26502651
SILValue Function) {
26512652
return createLinearFunctionExtract(Loc, Extractee, Function,
2652-
Function.getOwnershipKind());
2653+
Function->getOwnershipKind());
26532654
}
26542655

26552656
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: 6 additions & 5 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,10 @@ 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 {
672-
return Value->getOwnershipKind();
673-
}
671+
LLVM_ATTRIBUTE_DEPRECATED(
672+
ValueOwnershipKind getOwnershipKind()
673+
const { return Value->getOwnershipKind(); },
674+
"Please use ValueBase::getOwnershipKind()");
674675

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

684685
inline bool ValueOwnershipKind::isCompatibleWith(SILValue other) const {
685-
return isCompatibleWith(other.getOwnershipKind());
686+
return isCompatibleWith(other->getOwnershipKind());
686687
}
687688

688689
/// 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ namespace swift {
3030

3131
/// Returns true if this value requires OSSA cleanups.
3232
inline bool requiresOSSACleanup(SILValue v) {
33-
return v->getFunction()->hasOwnership()
34-
&& v.getOwnershipKind() != OwnershipKind::None
35-
&& v.getOwnershipKind() != OwnershipKind::Unowned;
33+
return v->getFunction()->hasOwnership() &&
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)