SIL Serialization: perform SIL linking right after SILGen.

Add a SILLinkage mode "Deserialized" to make sure IRGen will emit
hidden symbols for deserialized SILFunction.

Inside SIL linker, set Linkage to external if we only have a declaration for
a callee function.

Both sil block and decl block in a module can emit an array of substitutions.
To share the serialization between SILSerializer and Serializer, we modify
the interface to pass in the abbreviation codes to write functions and to
pass in a cursor to read functions.

We now correctly handle the serialization of Substitutions in SpecializeInst.

For a deserialized SILFunction, we now temporarily set its SILLocation and 
DebugScope to an empty FileLocation. Once mandatory inliner sets the SILLocation
to the location of ApplyInst, a null SILLocation and a null DebugScope
may work for a deserialized SILFunction.

Update testing cases to reflect that we are now inlining transparent functions
from modules, or to disable SILDeserializer for now (I am not sure how to update
those testing cases).


Swift SVN r8582
This commit is contained in:
Manman Ren
2013-09-24 00:44:54 +00:00
parent 65f5a901e2
commit be3a4101ed
12 changed files with 156 additions and 94 deletions

View File

@@ -1055,16 +1055,14 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
ListOfValues.push_back((unsigned)SpI->getOperand().getType().getCategory());
ListOfValues.push_back(addValueRef(SpI->getOperand()));
ListOfValues.push_back(SpI->getOperand().getResultNumber());
for (auto Sub : SpI->getSubstitutions()) {
ListOfValues.push_back(S.addTypeRef(Sub.Archetype));
ListOfValues.push_back(S.addTypeRef(Sub.Replacement));
}
ListOfValues.push_back(SpI->getSubstitutions().size());
SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord,
SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(),
S.addTypeRef(SpI->getType().getSwiftRValueType()),
(unsigned)SpI->getType().getCategory(), ListOfValues);
S.writeSubstitutions(SpI->getSubstitutions(), SILAbbrCodes);
break;
}
}
@@ -1105,7 +1103,7 @@ void SILSerializer::writeFuncTable() {
void SILSerializer::writeAllSILFunctions(const SILModule *M) {
{
BCBlockRAII subBlock(Out, SIL_BLOCK_ID, 4);
BCBlockRAII subBlock(Out, SIL_BLOCK_ID, 5);
registerSILAbbr<SILFunctionLayout>();
registerSILAbbr<SILBasicBlockLayout>();
registerSILAbbr<SILOneValueOneOperandLayout>();
@@ -1117,6 +1115,16 @@ void SILSerializer::writeAllSILFunctions(const SILModule *M) {
registerSILAbbr<SILInstApplyLayout>();
registerSILAbbr<SILInstNoOperandLayout>();
// Register the abbreviation codes so these layouts can exist in both
// decl blocks and sil blocks.
// We have to make sure BOUND_GENERIC_SUBSTITUTION does not overlap with
// SIL-specific records.
registerSILAbbr<decls_block::BoundGenericSubstitutionLayout>();
registerSILAbbr<decls_block::NoConformanceLayout>();
registerSILAbbr<decls_block::NormalProtocolConformanceLayout>();
registerSILAbbr<decls_block::SpecializedProtocolConformanceLayout>();
registerSILAbbr<decls_block::InheritedProtocolConformanceLayout>();
// Go through all SILFunctions in M, and if it is transparent,
// write out the SILFunction.
if (M && (EnableSerialize || EnableSerializeAll)) {