Skip to content

Commit f19f8b7

Browse files
committed
Merge pull request #431 from apple/revert-420-master
Revert "Fix TODO by removing unneeded ShouldSerializeAll parameters."
2 parents a1c9a72 + 54dcae4 commit f19f8b7

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/Serialization/SerializeSIL.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ namespace {
167167
<< " for layout " << Layout::Code << "\n");
168168
}
169169

170+
// TODO: this is not required anymore. Remove it.
171+
bool ShouldSerializeAll;
172+
170173
/// Helper function to update ListOfValues for MethodInst. Format:
171174
/// Attr, SILDeclRef (DeclID, Kind, uncurryLevel, IsObjC), and an operand.
172175
void handleMethodInst(const MethodInst *MI, SILValue operand,
@@ -202,8 +205,8 @@ namespace {
202205

203206
public:
204207
SILSerializer(Serializer &S, ASTContext &Ctx,
205-
llvm::BitstreamWriter &Out)
206-
: S(S), Ctx(Ctx), Out(Out) {}
208+
llvm::BitstreamWriter &Out, bool serializeAll)
209+
: S(S), Ctx(Ctx), Out(Out), ShouldSerializeAll(serializeAll) {}
207210

208211
void writeSILModule(const SILModule *SILMod);
209212
};
@@ -1694,23 +1697,28 @@ void SILSerializer::writeSILBlock(const SILModule *SILMod) {
16941697
// FIXME: Resilience: could write out vtable for fragile classes.
16951698
const DeclContext *assocDC = SILMod->getAssociatedContext();
16961699
for (const SILVTable &vt : SILMod->getVTables()) {
1697-
if (vt.getClass()->isChildContextOf(assocDC))
1700+
if (ShouldSerializeAll &&
1701+
vt.getClass()->isChildContextOf(assocDC))
16981702
writeSILVTable(vt);
16991703
}
17001704

1701-
// Write out WitnessTables.
1705+
// Write out WitnessTables. For now, write out only if EnableSerializeAll.
17021706
for (const SILWitnessTable &wt : SILMod->getWitnessTables()) {
1703-
if (wt.getConformance()->getDeclContext()->isChildContextOf(assocDC))
1707+
if (ShouldSerializeAll &&
1708+
wt.getConformance()->getDeclContext()->isChildContextOf(assocDC))
17041709
writeSILWitnessTable(wt);
17051710
}
17061711

17071712
// Go through all the SILFunctions in SILMod and write out any
17081713
// mandatory function bodies.
17091714
for (const SILFunction &F : *SILMod) {
1710-
if (shouldEmitFunctionBody(F))
1715+
if (shouldEmitFunctionBody(F) || ShouldSerializeAll)
17111716
writeSILFunction(F);
17121717
}
17131718

1719+
if (ShouldSerializeAll)
1720+
return;
1721+
17141722
// Now write function declarations for every function we've
17151723
// emitted a reference to without emitting a function body for.
17161724
for (const SILFunction &F : *SILMod) {
@@ -1724,10 +1732,10 @@ void SILSerializer::writeSILModule(const SILModule *SILMod) {
17241732
writeIndexTables();
17251733
}
17261734

1727-
void Serializer::writeSIL(const SILModule *SILMod) {
1735+
void Serializer::writeSIL(const SILModule *SILMod, bool serializeAllSIL) {
17281736
if (!SILMod)
17291737
return;
17301738

1731-
SILSerializer SILSer(*this, M->getASTContext(), Out);
1739+
SILSerializer SILSer(*this, M->getASTContext(), Out, serializeAllSIL);
17321740
SILSer.writeSILModule(SILMod);
17331741
}

0 commit comments

Comments
 (0)