Skip to content

Commit f4bab4c

Browse files
committed
[SIL] Handle KeyPathComponentKind::Method in helpers.
1 parent 13e1178 commit f4bab4c

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
@@ -2972,6 +2972,7 @@ bool KeyPathPatternComponent::isComputedSettablePropertyMutating() const {
29722972
switch (getKind()) {
29732973
case Kind::StoredProperty:
29742974
case Kind::GettableProperty:
2975+
case Kind::Method:
29752976
case Kind::OptionalChain:
29762977
case Kind::OptionalWrap:
29772978
case Kind::OptionalForce:
@@ -2999,6 +3000,7 @@ forEachRefcountableReference(const KeyPathPatternComponent &component,
29993000
case KeyPathPatternComponent::Kind::SettableProperty:
30003001
forFunction(component.getComputedPropertyForSettable());
30013002
LLVM_FALLTHROUGH;
3003+
case KeyPathPatternComponent::Kind::Method:
30023004
case KeyPathPatternComponent::Kind::GettableProperty:
30033005
forFunction(component.getComputedPropertyForGettable());
30043006

@@ -3053,7 +3055,8 @@ KeyPathPattern::get(SILModule &M, CanGenericSignature signature,
30533055
case KeyPathPatternComponent::Kind::OptionalForce:
30543056
case KeyPathPatternComponent::Kind::TupleElement:
30553057
break;
3056-
3058+
3059+
case KeyPathPatternComponent::Kind::Method:
30573060
case KeyPathPatternComponent::Kind::GettableProperty:
30583061
case KeyPathPatternComponent::Kind::SettableProperty:
30593062
for (auto &index : component.getArguments()) {
@@ -3135,7 +3138,8 @@ void KeyPathPattern::Profile(llvm::FoldingSetNodeID &ID,
31353138
case KeyPathPatternComponent::Kind::TupleElement:
31363139
ID.AddInteger(component.getTupleIndex());
31373140
break;
3138-
3141+
3142+
case KeyPathPatternComponent::Kind::Method:
31393143
case KeyPathPatternComponent::Kind::SettableProperty:
31403144
ID.AddPointer(component.getComputedPropertyForSettable());
31413145
LLVM_FALLTHROUGH;
@@ -3260,7 +3264,8 @@ visitReferencedFunctionsAndMethods(
32603264
case KeyPathPatternComponent::Kind::SettableProperty:
32613265
functionCallBack(getComputedPropertyForSettable());
32623266
LLVM_FALLTHROUGH;
3263-
case KeyPathPatternComponent::Kind::GettableProperty: {
3267+
case KeyPathPatternComponent::Kind::GettableProperty:
3268+
case KeyPathPatternComponent::Kind::Method: {
32643269
functionCallBack(getComputedPropertyForGettable());
32653270
auto id = getComputedPropertyId();
32663271
switch (id.getKind()) {

lib/SIL/IR/SILPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3097,7 +3097,8 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
30973097
break;
30983098
}
30993099
case KeyPathPatternComponent::Kind::GettableProperty:
3100-
case KeyPathPatternComponent::Kind::SettableProperty: {
3100+
case KeyPathPatternComponent::Kind::SettableProperty:
3101+
case KeyPathPatternComponent::Kind::Method: {
31013102
*this << (kind == KeyPathPatternComponent::Kind::GettableProperty
31023103
? "gettable_property $" : "settable_property $")
31033104
<< 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(),
@@ -5917,6 +5918,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
59175918
switch (component.getKind()) {
59185919
case KeyPathPatternComponent::Kind::GettableProperty:
59195920
case KeyPathPatternComponent::Kind::SettableProperty:
5921+
case KeyPathPatternComponent::Kind::Method:
59205922
hasIndices = !component.getArguments().empty();
59215923
break;
59225924

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)