@@ -167,6 +167,9 @@ namespace {
167
167
<< " for layout " << Layout::Code << " \n " );
168
168
}
169
169
170
+ // TODO: this is not required anymore. Remove it.
171
+ bool ShouldSerializeAll;
172
+
170
173
// / Helper function to update ListOfValues for MethodInst. Format:
171
174
// / Attr, SILDeclRef (DeclID, Kind, uncurryLevel, IsObjC), and an operand.
172
175
void handleMethodInst (const MethodInst *MI, SILValue operand,
@@ -202,8 +205,8 @@ namespace {
202
205
203
206
public:
204
207
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) {}
207
210
208
211
void writeSILModule (const SILModule *SILMod);
209
212
};
@@ -1694,23 +1697,28 @@ void SILSerializer::writeSILBlock(const SILModule *SILMod) {
1694
1697
// FIXME: Resilience: could write out vtable for fragile classes.
1695
1698
const DeclContext *assocDC = SILMod->getAssociatedContext ();
1696
1699
for (const SILVTable &vt : SILMod->getVTables ()) {
1697
- if (vt.getClass ()->isChildContextOf (assocDC))
1700
+ if (ShouldSerializeAll &&
1701
+ vt.getClass ()->isChildContextOf (assocDC))
1698
1702
writeSILVTable (vt);
1699
1703
}
1700
1704
1701
- // Write out WitnessTables.
1705
+ // Write out WitnessTables. For now, write out only if EnableSerializeAll.
1702
1706
for (const SILWitnessTable &wt : SILMod->getWitnessTables ()) {
1703
- if (wt.getConformance ()->getDeclContext ()->isChildContextOf (assocDC))
1707
+ if (ShouldSerializeAll &&
1708
+ wt.getConformance ()->getDeclContext ()->isChildContextOf (assocDC))
1704
1709
writeSILWitnessTable (wt);
1705
1710
}
1706
1711
1707
1712
// Go through all the SILFunctions in SILMod and write out any
1708
1713
// mandatory function bodies.
1709
1714
for (const SILFunction &F : *SILMod) {
1710
- if (shouldEmitFunctionBody (F))
1715
+ if (shouldEmitFunctionBody (F) || ShouldSerializeAll )
1711
1716
writeSILFunction (F);
1712
1717
}
1713
1718
1719
+ if (ShouldSerializeAll)
1720
+ return ;
1721
+
1714
1722
// Now write function declarations for every function we've
1715
1723
// emitted a reference to without emitting a function body for.
1716
1724
for (const SILFunction &F : *SILMod) {
@@ -1724,10 +1732,10 @@ void SILSerializer::writeSILModule(const SILModule *SILMod) {
1724
1732
writeIndexTables ();
1725
1733
}
1726
1734
1727
- void Serializer::writeSIL (const SILModule *SILMod) {
1735
+ void Serializer::writeSIL (const SILModule *SILMod, bool serializeAllSIL ) {
1728
1736
if (!SILMod)
1729
1737
return ;
1730
1738
1731
- SILSerializer SILSer (*this , M->getASTContext (), Out);
1739
+ SILSerializer SILSer (*this , M->getASTContext (), Out, serializeAllSIL );
1732
1740
SILSer.writeSILModule (SILMod);
1733
1741
}
0 commit comments