@@ -26,31 +26,29 @@ bool swift::isValueAddressOrTrivial(SILValue v) {
26
26
}
27
27
28
28
// These operations forward both owned and guaranteed ownership.
29
- //
30
- // FIXME: Should be implemented as a SILInstruction type check-cast.
31
- static bool isOwnershipForwardingValueKind (SILNodeKind kind) {
29
+ static bool isOwnershipForwardingInstructionKind (SILInstructionKind kind) {
32
30
switch (kind) {
33
- case SILNodeKind ::TupleInst:
34
- case SILNodeKind ::StructInst:
35
- case SILNodeKind ::EnumInst:
36
- case SILNodeKind ::DifferentiableFunctionInst:
37
- case SILNodeKind ::LinearFunctionInst:
38
- case SILNodeKind ::OpenExistentialRefInst:
39
- case SILNodeKind ::UpcastInst:
40
- case SILNodeKind ::UncheckedValueCastInst:
41
- case SILNodeKind ::UncheckedRefCastInst:
42
- case SILNodeKind ::ConvertFunctionInst:
43
- case SILNodeKind ::RefToBridgeObjectInst:
44
- case SILNodeKind ::BridgeObjectToRefInst:
45
- case SILNodeKind ::UnconditionalCheckedCastInst:
46
- case SILNodeKind ::UncheckedEnumDataInst:
47
- case SILNodeKind ::SelectEnumInst:
48
- case SILNodeKind ::SwitchEnumInst:
49
- case SILNodeKind ::CheckedCastBranchInst:
50
- case SILNodeKind ::DestructureStructInst:
51
- case SILNodeKind ::DestructureTupleInst:
52
- case SILNodeKind ::MarkDependenceInst:
53
- case SILNodeKind ::InitExistentialRefInst:
31
+ case SILInstructionKind ::TupleInst:
32
+ case SILInstructionKind ::StructInst:
33
+ case SILInstructionKind ::EnumInst:
34
+ case SILInstructionKind ::DifferentiableFunctionInst:
35
+ case SILInstructionKind ::LinearFunctionInst:
36
+ case SILInstructionKind ::OpenExistentialRefInst:
37
+ case SILInstructionKind ::UpcastInst:
38
+ case SILInstructionKind ::UncheckedValueCastInst:
39
+ case SILInstructionKind ::UncheckedRefCastInst:
40
+ case SILInstructionKind ::ConvertFunctionInst:
41
+ case SILInstructionKind ::RefToBridgeObjectInst:
42
+ case SILInstructionKind ::BridgeObjectToRefInst:
43
+ case SILInstructionKind ::UnconditionalCheckedCastInst:
44
+ case SILInstructionKind ::UncheckedEnumDataInst:
45
+ case SILInstructionKind ::SelectEnumInst:
46
+ case SILInstructionKind ::SwitchEnumInst:
47
+ case SILInstructionKind ::CheckedCastBranchInst:
48
+ case SILInstructionKind ::DestructureStructInst:
49
+ case SILInstructionKind ::DestructureTupleInst:
50
+ case SILInstructionKind ::MarkDependenceInst:
51
+ case SILInstructionKind ::InitExistentialRefInst:
54
52
return true ;
55
53
default :
56
54
return false ;
@@ -59,17 +57,17 @@ static bool isOwnershipForwardingValueKind(SILNodeKind kind) {
59
57
60
58
// These operations forward guaranteed ownership, but don't necessarily forward
61
59
// owned values.
62
- static bool isGuaranteedForwardingValueKind (SILNodeKind kind) {
60
+ static bool isGuaranteedForwardingInstructionKind (SILInstructionKind kind) {
63
61
switch (kind) {
64
- case SILNodeKind ::TupleExtractInst:
65
- case SILNodeKind ::StructExtractInst:
66
- case SILNodeKind ::DifferentiableFunctionExtractInst:
67
- case SILNodeKind ::LinearFunctionExtractInst:
68
- case SILNodeKind ::OpenExistentialValueInst:
69
- case SILNodeKind ::OpenExistentialBoxValueInst:
62
+ case SILInstructionKind ::TupleExtractInst:
63
+ case SILInstructionKind ::StructExtractInst:
64
+ case SILInstructionKind ::DifferentiableFunctionExtractInst:
65
+ case SILInstructionKind ::LinearFunctionExtractInst:
66
+ case SILInstructionKind ::OpenExistentialValueInst:
67
+ case SILInstructionKind ::OpenExistentialBoxValueInst:
70
68
return true ;
71
69
default :
72
- return isOwnershipForwardingValueKind (kind);
70
+ return isOwnershipForwardingInstructionKind (kind);
73
71
}
74
72
}
75
73
@@ -83,32 +81,34 @@ bool swift::canOpcodeForwardGuaranteedValues(SILValue value) {
83
81
return true ;
84
82
}
85
83
86
- auto *node = value->getRepresentativeSILNodeInObject ();
87
- bool result = isGuaranteedForwardingValueKind (node->getKind ());
84
+ auto *inst = value->getDefiningInstruction ();
85
+ if (!inst)
86
+ return false ;
87
+
88
+ bool result = isGuaranteedForwardingInstructionKind (inst->getKind ());
88
89
if (result) {
89
- assert (!isa<OwnedFirstArgForwardingSingleValueInst>(node ));
90
- assert (OwnershipForwardingMixin::isa (node ));
90
+ assert (!isa<OwnedFirstArgForwardingSingleValueInst>(inst ));
91
+ assert (OwnershipForwardingMixin::isa (inst ));
91
92
}
92
93
return result;
93
94
}
94
95
95
96
bool swift::canOpcodeForwardGuaranteedValues (Operand *use) {
96
97
auto *user = use->getUser ();
97
- auto kind = user->getKind ();
98
- bool result = isOwnershipForwardingValueKind (SILNodeKind (kind));
98
+ bool result = isOwnershipForwardingInstructionKind (user->getKind ());
99
99
if (result) {
100
100
assert (!isa<GuaranteedFirstArgForwardingSingleValueInst>(user));
101
101
assert (OwnershipForwardingMixin::isa (user));
102
102
}
103
103
return result;
104
104
}
105
105
106
- static bool isOwnedForwardingValueKind (SILNodeKind kind) {
106
+ static bool isOwnedForwardingValueKind (SILInstructionKind kind) {
107
107
switch (kind) {
108
- case SILNodeKind ::MarkUninitializedInst:
108
+ case SILInstructionKind ::MarkUninitializedInst:
109
109
return true ;
110
110
default :
111
- return isOwnershipForwardingValueKind (kind);
111
+ return isOwnershipForwardingInstructionKind (kind);
112
112
}
113
113
}
114
114
@@ -121,19 +121,21 @@ bool swift::canOpcodeForwardOwnedValues(SILValue value) {
121
121
assert (OwnershipForwardingMixin::isa (predTerm));
122
122
return true ;
123
123
}
124
- auto *node = value->getRepresentativeSILNodeInObject ();
125
- bool result = isOwnedForwardingValueKind (node->getKind ());
124
+ auto *inst = value->getDefiningInstruction ();
125
+ if (!inst)
126
+ return false ;
127
+
128
+ bool result = isOwnedForwardingValueKind (inst->getKind ());
126
129
if (result) {
127
- assert (!isa<GuaranteedFirstArgForwardingSingleValueInst>(node ));
128
- assert (OwnershipForwardingMixin::isa (node ));
130
+ assert (!isa<GuaranteedFirstArgForwardingSingleValueInst>(inst ));
131
+ assert (OwnershipForwardingMixin::isa (inst ));
129
132
}
130
133
return result;
131
134
}
132
135
133
136
bool swift::canOpcodeForwardOwnedValues (Operand *use) {
134
137
auto *user = use->getUser ();
135
- auto kind = SILNodeKind (user->getKind ());
136
- bool result = isOwnershipForwardingValueKind (kind);
138
+ bool result = isOwnershipForwardingInstructionKind (user->getKind ());
137
139
if (result) {
138
140
assert (OwnershipForwardingMixin::isa (user));
139
141
}
0 commit comments