Skip to content

Commit 39b48bb

Browse files
committed
[SIL] Handle KeyPathComponentKind::Method in helpers.
1 parent 807c323 commit 39b48bb

File tree

8 files changed

+20
-6
lines changed

8 files changed

+20
-6
lines changed

lib/IRGen/GenKeyPath.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ emitKeyPathComponent(IRGenModule &IGM,
811811
KeyPathComponentHeader::forExternalComponent(externalSubArgs.size())
812812
.getData());
813813
auto descriptor = IGM.getAddrOfLLVMVariableOrGOTEquivalent(
814-
LinkEntity::forPropertyDescriptor(externalDecl));
814+
LinkEntity::forPropertyDescriptor(externalDecl));
815815
fields.addRelativeAddress(descriptor);
816816
for (auto *arg : externalSubArgs)
817817
fields.addRelativeAddress(arg);

lib/SIL/IR/SILInstructions.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,6 +2933,7 @@ bool KeyPathPatternComponent::isComputedSettablePropertyMutating() const {
29332933
switch (getKind()) {
29342934
case Kind::StoredProperty:
29352935
case Kind::GettableProperty:
2936+
case Kind::Method:
29362937
case Kind::OptionalChain:
29372938
case Kind::OptionalWrap:
29382939
case Kind::OptionalForce:
@@ -2960,6 +2961,7 @@ forEachRefcountableReference(const KeyPathPatternComponent &component,
29602961
case KeyPathPatternComponent::Kind::SettableProperty:
29612962
forFunction(component.getComputedPropertyForSettable());
29622963
LLVM_FALLTHROUGH;
2964+
case KeyPathPatternComponent::Kind::Method:
29632965
case KeyPathPatternComponent::Kind::GettableProperty:
29642966
forFunction(component.getComputedPropertyForGettable());
29652967

@@ -3014,7 +3016,8 @@ KeyPathPattern::get(SILModule &M, CanGenericSignature signature,
30143016
case KeyPathPatternComponent::Kind::OptionalForce:
30153017
case KeyPathPatternComponent::Kind::TupleElement:
30163018
break;
3017-
3019+
3020+
case KeyPathPatternComponent::Kind::Method:
30183021
case KeyPathPatternComponent::Kind::GettableProperty:
30193022
case KeyPathPatternComponent::Kind::SettableProperty:
30203023
for (auto &index : component.getArguments()) {
@@ -3096,7 +3099,8 @@ void KeyPathPattern::Profile(llvm::FoldingSetNodeID &ID,
30963099
case KeyPathPatternComponent::Kind::TupleElement:
30973100
ID.AddInteger(component.getTupleIndex());
30983101
break;
3099-
3102+
3103+
case KeyPathPatternComponent::Kind::Method:
31003104
case KeyPathPatternComponent::Kind::SettableProperty:
31013105
ID.AddPointer(component.getComputedPropertyForSettable());
31023106
LLVM_FALLTHROUGH;
@@ -3221,7 +3225,8 @@ visitReferencedFunctionsAndMethods(
32213225
case KeyPathPatternComponent::Kind::SettableProperty:
32223226
functionCallBack(getComputedPropertyForSettable());
32233227
LLVM_FALLTHROUGH;
3224-
case KeyPathPatternComponent::Kind::GettableProperty: {
3228+
case KeyPathPatternComponent::Kind::GettableProperty:
3229+
case KeyPathPatternComponent::Kind::Method: {
32253230
functionCallBack(getComputedPropertyForGettable());
32263231
auto id = getComputedPropertyId();
32273232
switch (id.getKind()) {

lib/SIL/IR/SILPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3099,7 +3099,8 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
30993099
break;
31003100
}
31013101
case KeyPathPatternComponent::Kind::GettableProperty:
3102-
case KeyPathPatternComponent::Kind::SettableProperty: {
3102+
case KeyPathPatternComponent::Kind::SettableProperty:
3103+
case KeyPathPatternComponent::Kind::Method: {
31033104
*this << (kind == KeyPathPatternComponent::Kind::GettableProperty
31043105
? "gettable_property $" : "settable_property $")
31053106
<< component.getComponentType() << ", "

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ void verifyKeyPathComponent(SILModule &M,
394394
}
395395

396396
case KeyPathPatternComponent::Kind::GettableProperty:
397-
case KeyPathPatternComponent::Kind::SettableProperty: {
397+
case KeyPathPatternComponent::Kind::SettableProperty:
398+
case KeyPathPatternComponent::Kind::Method: {
398399
if (forPropertyDescriptor) {
399400
require(component.getArguments().empty() && !component.getIndexEquals() &&
400401
!component.getIndexHash(),
@@ -5898,6 +5899,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
58985899
switch (component.getKind()) {
58995900
case KeyPathPatternComponent::Kind::GettableProperty:
59005901
case KeyPathPatternComponent::Kind::SettableProperty:
5902+
case KeyPathPatternComponent::Kind::Method:
59015903
hasIndices = !component.getArguments().empty();
59025904
break;
59035905

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ bool swift::tryOptimizeKeypathOffsetOf(ApplyInst *AI,
423423
break;
424424
case KeyPathPatternComponent::Kind::GettableProperty:
425425
case KeyPathPatternComponent::Kind::SettableProperty:
426+
case KeyPathPatternComponent::Kind::Method:
426427
// We cannot predict the offset of fields in resilient types, because it's
427428
// unknown if a resilient field is a computed or stored property.
428429
if (component.getExternalDecl())

lib/SILOptimizer/Transforms/AccessEnforcementWMO.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ bool GlobalAccessRemoval::visitInstruction(SILInstruction *I) {
230230
break;
231231
case KeyPathPatternComponent::Kind::GettableProperty:
232232
case KeyPathPatternComponent::Kind::SettableProperty:
233+
case KeyPathPatternComponent::Kind::Method:
233234
case KeyPathPatternComponent::Kind::OptionalChain:
234235
case KeyPathPatternComponent::Kind::OptionalForce:
235236
case KeyPathPatternComponent::Kind::OptionalWrap:

lib/SILOptimizer/Utils/KeyPathProjector.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ class CompleteKeyPathProjector : public KeyPathProjector {
641641
(comp, std::move(parent), loc, builder);
642642
break;
643643
case KeyPathPatternComponent::Kind::GettableProperty:
644+
case KeyPathPatternComponent::Kind::Method:
644645
projector = std::make_unique<GettablePropertyProjector>
645646
(keyPath, comp, std::move(parent), keyPath->getSubstitutions(),
646647
beginAccess, loc, builder);

lib/Serialization/SerializeSIL.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,9 @@ SILSerializer::writeKeyPathPatternComponent(
902902
};
903903

904904
switch (component.getKind()) {
905+
case KeyPathPatternComponent::Kind::Method:
906+
printf("SerializeSIL:writeKeyPathPatternComponent");
907+
break;
905908
case KeyPathPatternComponent::Kind::StoredProperty:
906909
handleComponentCommon(KeyPathComponentKindEncoding::StoredProperty);
907910
ListOfValues.push_back(S.addDeclRef(component.getStoredPropertyDecl()));

0 commit comments

Comments
 (0)