mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
IRGen: Deserialize SIL witness tables and shared-linkage definitions by need.
Code may end up indirectly using a witness table for a Clang-imported type by inlining code that used the conformance from another module, in which case we need to ensure we have a local definition at hand in the inlining module so we can have something to link against independently. This needs to be fixed from both sides: - During serialization, serialize not only witness tables from the current module, but from Clang-imported modules too, so that their definitions can be used by other modules that inline code from the current module - During IRGen, when we emit a reference to a SILWitnessTable or SILFunction declaration with shared linkage, attempt to deserialize the definition on demand Fixes rdar://problem/38687726.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "Linker.h"
|
||||
#include "swift/SIL/SILVisitor.h"
|
||||
#include "swift/SIL/SILValue.h"
|
||||
#include "swift/ClangImporter/ClangModule.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
@@ -781,6 +782,23 @@ bool SILModule::isNoReturnBuiltinOrIntrinsic(Identifier Name) {
|
||||
}
|
||||
}
|
||||
|
||||
bool SILModule::
|
||||
shouldSerializeEntitiesAssociatedWithDeclContext(const DeclContext *DC) const {
|
||||
// Serialize entities associated with this module's associated context.
|
||||
if (DC->isChildContextOf(getAssociatedContext())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Serialize entities associated with clang modules, since other entities
|
||||
// may depend on them, and someone who deserializes those entities may not
|
||||
// have their own copy.
|
||||
if (isa<ClangModuleUnit>(DC->getModuleScopeContext())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Returns true if it is the OnoneSupport module.
|
||||
bool SILModule::isOnoneSupportModule() const {
|
||||
return getSwiftModule()->getName().str() == SWIFT_ONONE_SUPPORT;
|
||||
|
||||
Reference in New Issue
Block a user