mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user