Skip to content

Commit 944267d

Browse files
committed
SIL: Remove SILWitnessTable::AssociatedConformanceWitness::SubstType
1 parent a9ae485 commit 944267d

File tree

11 files changed

+10
-28
lines changed

11 files changed

+10
-28
lines changed

SwiftCompilerSources/Sources/SIL/WitnessTable.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ public struct WitnessTable : CustomStringConvertible, NoReflectionChildren {
7171
OptionalBridgedFunction(obj: witness?.bridged.obj))
7272
case .associatedType(let requirement, let witness):
7373
return BridgedWitnessTableEntry.createAssociatedType(requirement.bridged, witness.bridged)
74-
case .associatedConformance(let requirement, let substType, let witness):
74+
case .associatedConformance(let requirement, _, let witness):
7575
return BridgedWitnessTableEntry.createAssociatedConformance(requirement.bridged,
76-
substType.bridged,
7776
witness.bridged)
7877
case .baseProtocol(let requirement, let witness):
7978
return BridgedWitnessTableEntry.createBaseProtocol(requirement.bridged, witness.bridged)

include/swift/SIL/SILBridging.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,6 @@ struct BridgedWitnessTableEntry {
10761076
BridgedCanType witness);
10771077
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE
10781078
static BridgedWitnessTableEntry createAssociatedConformance(BridgedCanType requirement,
1079-
BridgedCanType substType,
10801079
BridgedConformance witness);
10811080
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE
10821081
static BridgedWitnessTableEntry createBaseProtocol(BridgedDeclObj requirement,

include/swift/SIL/SILBridgingImpl.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,8 +1918,9 @@ BridgedCanType BridgedWitnessTableEntry::getAssociatedConformanceRequirement() c
19181918
return unbridged().getAssociatedConformanceWitness().Requirement;
19191919
}
19201920

1921+
// FIXME: This is now redundant
19211922
BridgedCanType BridgedWitnessTableEntry::getAssociatedConformanceSubstType() const {
1922-
return {unbridged().getAssociatedConformanceWitness().SubstType};
1923+
return {unbridged().getAssociatedConformanceWitness().Witness.getType()->getCanonicalType()};
19231924
}
19241925

19251926
BridgedConformance BridgedWitnessTableEntry::getAssociatedConformanceWitness() const {
@@ -1953,11 +1954,9 @@ BridgedWitnessTableEntry BridgedWitnessTableEntry::createAssociatedType(BridgedD
19531954
}
19541955

19551956
BridgedWitnessTableEntry BridgedWitnessTableEntry::createAssociatedConformance(BridgedCanType requirement,
1956-
BridgedCanType substType,
19571957
BridgedConformance witness) {
19581958
return bridge(swift::SILWitnessTable::Entry(
19591959
swift::SILWitnessTable::AssociatedConformanceWitness{requirement.unbridged(),
1960-
substType.unbridged(),
19611960
witness.unbridged()}));
19621961
}
19631962

include/swift/SIL/SILWitnessTable.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ class SILWitnessTable : public llvm::ilist_node<SILWitnessTable>,
6666
struct AssociatedConformanceWitness {
6767
/// The subject type of the associated requirement.
6868
CanType Requirement;
69-
/// FIXME: Temporary.
70-
CanType SubstType;
7169
/// The ProtocolConformanceRef satisfying the requirement.
7270
ProtocolConformanceRef Witness;
7371
};

lib/SIL/IR/SILPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4350,7 +4350,7 @@ void SILWitnessTable::Entry::print(llvm::raw_ostream &out, bool verbose,
43504350
conformance.getConcrete()->printName(out, options);
43514351
else {
43524352
out << "dependent ";
4353-
assocProtoWitness.SubstType->print(out, options);
4353+
assocProtoWitness.Witness.getType()->print(out, options);
43544354
}
43554355
break;
43564356
}

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8229,15 +8229,13 @@ static bool parseSILWitnessTableEntry(
82298229
P.parseToken(tok::colon, diag::expected_sil_witness_colon))
82308230
return true;
82318231

8232-
CanType substType;
82338232
ProtocolConformanceRef conformance;
82348233
if (P.Tok.getText() != "dependent") {
82358234
auto concrete =
82368235
witnessState.parseProtocolConformance();
82378236
// Ignore invalid and abstract witness entries.
82388237
if (concrete.isInvalid() || !concrete.isConcrete())
82398238
return false;
8240-
substType = concrete.getConcrete()->getType()->getCanonicalType();
82418239
conformance = concrete;
82428240
} else {
82438241
P.consumeToken();
@@ -8261,15 +8259,13 @@ static bool parseSILWitnessTableEntry(
82618259
if (Ty->hasError())
82628260
return true;
82638261

8264-
substType = Ty->getCanonicalType();
82658262
conformance = ProtocolConformanceRef::forAbstract(
82668263
Ty->getCanonicalType(), proto);
82678264
}
82688265

82698266
if (EntryKeyword.str() == "associated_conformance")
82708267
witnessEntries.push_back(
82718268
SILWitnessTable::AssociatedConformanceWitness{assocOrSubject,
8272-
substType,
82738269
conformance});
82748270
else
82758271
conditionalConformances.push_back(conformance);

lib/SILGen/SILGenType.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,8 @@ class SILGenConformance : public SILGenWitnessTable<SILGenConformance> {
692692
Conformance->getAssociatedConformance(req.getAssociation(),
693693
req.getAssociatedRequirement());
694694
SGM.useConformance(assocConformance);
695-
696-
auto substType = (assocConformance
697-
? assocConformance.getType()
698-
: ErrorType::get(SGM.getASTContext()))->getCanonicalType();
699695
Entries.push_back(SILWitnessTable::AssociatedConformanceWitness{
700-
req.getAssociation(), substType, assocConformance});
696+
req.getAssociation(), assocConformance});
701697
}
702698

703699
void addConditionalRequirements() {
@@ -1125,7 +1121,7 @@ class SILGenDefaultWitnessTable
11251121
return addMissingDefault();
11261122

11271123
auto entry = SILWitnessTable::AssociatedConformanceWitness{
1128-
req.getAssociation(), req.getAssociation(), witness};
1124+
req.getAssociation(), witness};
11291125
DefaultWitnesses.push_back(entry);
11301126
}
11311127
};

lib/Serialization/DeserializeSIL.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4488,15 +4488,12 @@ void SILDeserializer::readWitnessTableEntries(
44884488
});
44894489
} else if (kind == SIL_WITNESS_ASSOC_PROTOCOL) {
44904490
TypeID origTypeId;
4491-
DeclID substTypeId;
44924491
ProtocolConformanceID conformanceId;
4493-
WitnessAssocProtocolLayout::readRecord(scratch, origTypeId, substTypeId,
4494-
conformanceId);
4492+
WitnessAssocProtocolLayout::readRecord(scratch, origTypeId, conformanceId);
44954493
CanType origType = MF->getType(origTypeId)->getCanonicalType();
4496-
CanType substType = MF->getType(substTypeId)->getCanonicalType();
44974494
auto conformance = MF->getConformance(conformanceId);
44984495
witnessEntries.push_back(SILWitnessTable::AssociatedConformanceWitness{
4499-
origType, substType, conformance
4496+
origType, conformance
45004497
});
45014498
} else if (kind == SIL_WITNESS_ASSOC_ENTRY) {
45024499
DeclID assocId;

lib/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5858
/// describe what change you made. The content of this comment isn't important;
5959
/// it just ensures a conflict if two people change the module format.
6060
/// Don't worry about adhering to the 80-column limit for this line.
61-
const uint16_t SWIFTMODULE_VERSION_MINOR = 936; // Remove SILWitnessTable::ConditionalConformance
61+
const uint16_t SWIFTMODULE_VERSION_MINOR = 937; // Simplify SILWitnessTable
6262

6363
/// A standard hash seed used for all string hashes in a serialized module.
6464
///

lib/Serialization/SILFormat.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ namespace sil_block {
249249
using WitnessAssocProtocolLayout = BCRecordLayout<
250250
SIL_WITNESS_ASSOC_PROTOCOL,
251251
TypeIDField, // ID of requirement subject type
252-
TypeIDField, // ID of substituted subject type
253252
ProtocolConformanceIDField
254253
>;
255254

lib/Serialization/SerializeSIL.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3401,13 +3401,12 @@ void SILSerializer::writeSILWitnessTableEntry(
34013401
auto &assoc = entry.getAssociatedConformanceWitness();
34023402

34033403
auto requirementID = S.addTypeRef(assoc.Requirement);
3404-
auto substTypeID = S.addTypeRef(assoc.SubstType);
34053404
auto conformanceID = S.addConformanceRef(assoc.Witness);
34063405

34073406
WitnessAssocProtocolLayout::emitRecord(
34083407
Out, ScratchRecord,
34093408
SILAbbrCodes[WitnessAssocProtocolLayout::Code],
3410-
requirementID, substTypeID, conformanceID);
3409+
requirementID, conformanceID);
34113410
return;
34123411
}
34133412

0 commit comments

Comments
 (0)