diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp index 72f8fe06ff195..0a6deac3158f9 100644 --- a/lib/Serialization/SerializeSIL.cpp +++ b/lib/Serialization/SerializeSIL.cpp @@ -167,6 +167,9 @@ namespace { << " for layout " << Layout::Code << "\n"); } + // TODO: this is not required anymore. Remove it. + bool ShouldSerializeAll; + /// Helper function to update ListOfValues for MethodInst. Format: /// Attr, SILDeclRef (DeclID, Kind, uncurryLevel, IsObjC), and an operand. void handleMethodInst(const MethodInst *MI, SILValue operand, @@ -202,8 +205,8 @@ namespace { public: SILSerializer(Serializer &S, ASTContext &Ctx, - llvm::BitstreamWriter &Out) - : S(S), Ctx(Ctx), Out(Out) {} + llvm::BitstreamWriter &Out, bool serializeAll) + : S(S), Ctx(Ctx), Out(Out), ShouldSerializeAll(serializeAll) {} void writeSILModule(const SILModule *SILMod); }; @@ -1694,23 +1697,28 @@ void SILSerializer::writeSILBlock(const SILModule *SILMod) { // FIXME: Resilience: could write out vtable for fragile classes. const DeclContext *assocDC = SILMod->getAssociatedContext(); for (const SILVTable &vt : SILMod->getVTables()) { - if (vt.getClass()->isChildContextOf(assocDC)) + if (ShouldSerializeAll && + vt.getClass()->isChildContextOf(assocDC)) writeSILVTable(vt); } - // Write out WitnessTables. + // Write out WitnessTables. For now, write out only if EnableSerializeAll. for (const SILWitnessTable &wt : SILMod->getWitnessTables()) { - if (wt.getConformance()->getDeclContext()->isChildContextOf(assocDC)) + if (ShouldSerializeAll && + wt.getConformance()->getDeclContext()->isChildContextOf(assocDC)) writeSILWitnessTable(wt); } // Go through all the SILFunctions in SILMod and write out any // mandatory function bodies. for (const SILFunction &F : *SILMod) { - if (shouldEmitFunctionBody(F)) + if (shouldEmitFunctionBody(F) || ShouldSerializeAll) writeSILFunction(F); } + if (ShouldSerializeAll) + return; + // Now write function declarations for every function we've // emitted a reference to without emitting a function body for. for (const SILFunction &F : *SILMod) { @@ -1724,10 +1732,10 @@ void SILSerializer::writeSILModule(const SILModule *SILMod) { writeIndexTables(); } -void Serializer::writeSIL(const SILModule *SILMod) { +void Serializer::writeSIL(const SILModule *SILMod, bool serializeAllSIL) { if (!SILMod) return; - SILSerializer SILSer(*this, M->getASTContext(), Out); + SILSerializer SILSer(*this, M->getASTContext(), Out, serializeAllSIL); SILSer.writeSILModule(SILMod); }