|
|
|
@@ -24,12 +24,26 @@ using namespace swift;
|
|
|
|
using namespace dependencies;
|
|
|
|
using namespace dependencies;
|
|
|
|
using namespace module_dependency_cache_serialization;
|
|
|
|
using namespace module_dependency_cache_serialization;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
ModuleDependencyKind &operator++(ModuleDependencyKind &e) {
|
|
|
|
|
|
|
|
if (e == ModuleDependencyKind::LastKind) {
|
|
|
|
|
|
|
|
llvm_unreachable(
|
|
|
|
|
|
|
|
"Attempting to increment last enum value on ModuleDependencyKind");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
e = ModuleDependencyKind(
|
|
|
|
|
|
|
|
static_cast<std::underlying_type<ModuleDependencyKind>::type>(e) + 1);
|
|
|
|
|
|
|
|
return e;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Deserialization
|
|
|
|
// MARK: Deserialization
|
|
|
|
namespace swift {
|
|
|
|
namespace swift {
|
|
|
|
|
|
|
|
|
|
|
|
class ModuleDependenciesCacheDeserializer {
|
|
|
|
class ModuleDependenciesCacheDeserializer {
|
|
|
|
std::vector<std::string> Identifiers;
|
|
|
|
std::vector<std::string> Identifiers;
|
|
|
|
std::vector<std::vector<uint64_t>> ArraysOfIdentifierIDs;
|
|
|
|
std::vector<std::vector<uint64_t>> ArraysOfIdentifierIDs;
|
|
|
|
|
|
|
|
std::vector<LinkLibrary> LinkLibraries;
|
|
|
|
|
|
|
|
std::vector<std::vector<uint64_t>> ArraysOfLinkLibraryIDs;
|
|
|
|
llvm::BitstreamCursor Cursor;
|
|
|
|
llvm::BitstreamCursor Cursor;
|
|
|
|
SmallVector<uint64_t, 64> Scratch;
|
|
|
|
SmallVector<uint64_t, 64> Scratch;
|
|
|
|
StringRef BlobData;
|
|
|
|
StringRef BlobData;
|
|
|
|
@@ -38,10 +52,12 @@ class ModuleDependenciesCacheDeserializer {
|
|
|
|
bool readSignature();
|
|
|
|
bool readSignature();
|
|
|
|
bool enterGraphBlock();
|
|
|
|
bool enterGraphBlock();
|
|
|
|
bool readMetadata();
|
|
|
|
bool readMetadata();
|
|
|
|
|
|
|
|
bool readLinkLibraries();
|
|
|
|
bool readGraph(ModuleDependenciesCache &cache);
|
|
|
|
bool readGraph(ModuleDependenciesCache &cache);
|
|
|
|
|
|
|
|
|
|
|
|
std::optional<std::string> getIdentifier(unsigned n);
|
|
|
|
std::optional<std::string> getIdentifier(unsigned n);
|
|
|
|
std::optional<std::vector<std::string>> getStringArray(unsigned n);
|
|
|
|
std::optional<std::vector<std::string>> getStringArray(unsigned n);
|
|
|
|
|
|
|
|
std::optional<std::vector<LinkLibrary>> getLinkLibraryArray(unsigned n);
|
|
|
|
std::optional<std::vector<ModuleDependencyID>>
|
|
|
|
std::optional<std::vector<ModuleDependencyID>>
|
|
|
|
getModuleDependencyIDArray(unsigned n);
|
|
|
|
getModuleDependencyIDArray(unsigned n);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -155,7 +171,6 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
|
|
|
|
|
|
|
|
bool hasCurrentModule = false;
|
|
|
|
bool hasCurrentModule = false;
|
|
|
|
std::string currentModuleName;
|
|
|
|
std::string currentModuleName;
|
|
|
|
unsigned currentContextHashID;
|
|
|
|
|
|
|
|
std::vector<ScannerImportStatementInfo> currentModuleImports;
|
|
|
|
std::vector<ScannerImportStatementInfo> currentModuleImports;
|
|
|
|
std::vector<ScannerImportStatementInfo> currentOptionalModuleImports;
|
|
|
|
std::vector<ScannerImportStatementInfo> currentOptionalModuleImports;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -163,6 +178,7 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
std::vector<ModuleDependencyID> importedClangDependenciesIDs;
|
|
|
|
std::vector<ModuleDependencyID> importedClangDependenciesIDs;
|
|
|
|
std::vector<ModuleDependencyID> crossImportOverlayDependenciesIDs;
|
|
|
|
std::vector<ModuleDependencyID> crossImportOverlayDependenciesIDs;
|
|
|
|
std::vector<ModuleDependencyID> swiftOverlayDependenciesIDs;
|
|
|
|
std::vector<ModuleDependencyID> swiftOverlayDependenciesIDs;
|
|
|
|
|
|
|
|
std::vector<LinkLibrary> linkLibraries;
|
|
|
|
std::vector<std::string> auxiliaryFiles;
|
|
|
|
std::vector<std::string> auxiliaryFiles;
|
|
|
|
|
|
|
|
|
|
|
|
while (!Cursor.AtEndOfStream()) {
|
|
|
|
while (!Cursor.AtEndOfStream()) {
|
|
|
|
@@ -208,18 +224,44 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case LINK_LIBRARY_NODE: {
|
|
|
|
|
|
|
|
unsigned libraryIdentifierID;
|
|
|
|
|
|
|
|
bool isFramework, shouldForceLoad;
|
|
|
|
|
|
|
|
LinkLibraryLayout::readRecord(Scratch,
|
|
|
|
|
|
|
|
libraryIdentifierID,
|
|
|
|
|
|
|
|
isFramework, shouldForceLoad);
|
|
|
|
|
|
|
|
auto libraryIdentifier = getIdentifier(libraryIdentifierID);
|
|
|
|
|
|
|
|
if (!libraryIdentifier)
|
|
|
|
|
|
|
|
llvm::report_fatal_error("Bad link library identifier");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LinkLibraries.push_back(LinkLibrary(libraryIdentifier.value(),
|
|
|
|
|
|
|
|
isFramework ? LibraryKind::Framework : LibraryKind::Library,
|
|
|
|
|
|
|
|
shouldForceLoad));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case LINK_LIBRARY_ARRAY_NODE: {
|
|
|
|
|
|
|
|
ArrayRef<uint64_t> identifierIDs;
|
|
|
|
|
|
|
|
LinkLibraryArrayLayout::readRecord(Scratch, identifierIDs);
|
|
|
|
|
|
|
|
ArraysOfLinkLibraryIDs.push_back(identifierIDs.vec());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case MODULE_NODE: {
|
|
|
|
case MODULE_NODE: {
|
|
|
|
hasCurrentModule = true;
|
|
|
|
hasCurrentModule = true;
|
|
|
|
unsigned moduleNameID, contextHashID,
|
|
|
|
unsigned moduleNameID,
|
|
|
|
moduleImportsArrayID, optionalModuleImportsArrayID,
|
|
|
|
moduleImportsArrayID, optionalModuleImportsArrayID,
|
|
|
|
|
|
|
|
linkLibraryArrayID,
|
|
|
|
importedSwiftDependenciesIDsArrayID,
|
|
|
|
importedSwiftDependenciesIDsArrayID,
|
|
|
|
importedClangDependenciesIDsArrayID,
|
|
|
|
importedClangDependenciesIDsArrayID,
|
|
|
|
crossImportOverlayDependenciesIDsArrayID,
|
|
|
|
crossImportOverlayDependenciesIDsArrayID,
|
|
|
|
swiftOverlayDependenciesIDsArrayID,
|
|
|
|
swiftOverlayDependenciesIDsArrayID,
|
|
|
|
moduleCacheKeyID, AuxiliaryFilesArrayID;
|
|
|
|
moduleCacheKeyID, AuxiliaryFilesArrayID;
|
|
|
|
ModuleInfoLayout::readRecord(Scratch, moduleNameID, contextHashID,
|
|
|
|
|
|
|
|
|
|
|
|
ModuleInfoLayout::readRecord(Scratch, moduleNameID,
|
|
|
|
moduleImportsArrayID,
|
|
|
|
moduleImportsArrayID,
|
|
|
|
optionalModuleImportsArrayID,
|
|
|
|
optionalModuleImportsArrayID,
|
|
|
|
|
|
|
|
linkLibraryArrayID,
|
|
|
|
importedSwiftDependenciesIDsArrayID,
|
|
|
|
importedSwiftDependenciesIDsArrayID,
|
|
|
|
importedClangDependenciesIDsArrayID,
|
|
|
|
importedClangDependenciesIDsArrayID,
|
|
|
|
crossImportOverlayDependenciesIDsArrayID,
|
|
|
|
crossImportOverlayDependenciesIDsArrayID,
|
|
|
|
@@ -229,10 +271,11 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
if (!moduleName)
|
|
|
|
if (!moduleName)
|
|
|
|
llvm::report_fatal_error("Bad module name");
|
|
|
|
llvm::report_fatal_error("Bad module name");
|
|
|
|
currentModuleName = *moduleName;
|
|
|
|
currentModuleName = *moduleName;
|
|
|
|
currentContextHashID = contextHashID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto importStrings = getStringArray(moduleImportsArrayID);
|
|
|
|
auto importStrings = getStringArray(moduleImportsArrayID);
|
|
|
|
auto optionalImportStrings = getStringArray(optionalModuleImportsArrayID);
|
|
|
|
auto optionalImportStrings = getStringArray(optionalModuleImportsArrayID);
|
|
|
|
|
|
|
|
// ACTODO: Proper import infos.
|
|
|
|
|
|
|
|
currentModuleImports.clear();
|
|
|
|
|
|
|
|
currentOptionalModuleImports.clear();
|
|
|
|
if (importStrings.has_value())
|
|
|
|
if (importStrings.has_value())
|
|
|
|
for (const auto &is : importStrings.value())
|
|
|
|
for (const auto &is : importStrings.value())
|
|
|
|
currentModuleImports.push_back(is);
|
|
|
|
currentModuleImports.push_back(is);
|
|
|
|
@@ -264,6 +307,11 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
if (!optionalSwiftOverlayDependenciesIDs)
|
|
|
|
if (!optionalSwiftOverlayDependenciesIDs)
|
|
|
|
llvm::report_fatal_error("Bad Swift Overlay dependencies: no qualified dependencies");
|
|
|
|
llvm::report_fatal_error("Bad Swift Overlay dependencies: no qualified dependencies");
|
|
|
|
swiftOverlayDependenciesIDs = optionalSwiftOverlayDependenciesIDs.value();
|
|
|
|
swiftOverlayDependenciesIDs = optionalSwiftOverlayDependenciesIDs.value();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto optionalLinkLibraries = getLinkLibraryArray(linkLibraryArrayID);
|
|
|
|
|
|
|
|
if (!optionalLinkLibraries)
|
|
|
|
|
|
|
|
llvm::report_fatal_error("Bad Link Libraries info");
|
|
|
|
|
|
|
|
linkLibraries = *optionalLinkLibraries;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -330,11 +378,11 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
if (!userModuleVersion)
|
|
|
|
if (!userModuleVersion)
|
|
|
|
llvm::report_fatal_error("Bad userModuleVersion");
|
|
|
|
llvm::report_fatal_error("Bad userModuleVersion");
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: LinkLibraries, MacroDependencies
|
|
|
|
// TODO: MacroDependencies
|
|
|
|
// Form the dependencies storage object
|
|
|
|
// Form the dependencies storage object
|
|
|
|
auto moduleDep = ModuleDependencyInfo::forSwiftInterfaceModule(
|
|
|
|
auto moduleDep = ModuleDependencyInfo::forSwiftInterfaceModule(
|
|
|
|
outputModulePath.value(), optionalSwiftInterfaceFile.value(),
|
|
|
|
outputModulePath.value(), optionalSwiftInterfaceFile.value(),
|
|
|
|
compiledCandidatesRefs, buildCommandRefs, {}, extraPCMRefs,
|
|
|
|
compiledCandidatesRefs, buildCommandRefs, linkLibraries, extraPCMRefs,
|
|
|
|
*contextHash, isFramework, isStatic, *rootFileSystemID, *moduleCacheKey,
|
|
|
|
*contextHash, isFramework, isStatic, *rootFileSystemID, *moduleCacheKey,
|
|
|
|
*userModuleVersion);
|
|
|
|
*userModuleVersion);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -403,11 +451,6 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
if (!hasCurrentModule)
|
|
|
|
if (!hasCurrentModule)
|
|
|
|
llvm::report_fatal_error(
|
|
|
|
llvm::report_fatal_error(
|
|
|
|
"Unexpected SWIFT_SOURCE_MODULE_DETAILS_NODE record");
|
|
|
|
"Unexpected SWIFT_SOURCE_MODULE_DETAILS_NODE record");
|
|
|
|
// Expected context hash ID is 0
|
|
|
|
|
|
|
|
if (currentContextHashID)
|
|
|
|
|
|
|
|
llvm::report_fatal_error(
|
|
|
|
|
|
|
|
"Unexpected context hash on MODULE_NODE corresponding to a "
|
|
|
|
|
|
|
|
"SWIFT_SOURCE_MODULE_DETAILS_NODE record");
|
|
|
|
|
|
|
|
unsigned extraPCMArgsArrayID, bridgingHeaderFileID, sourceFilesArrayID,
|
|
|
|
unsigned extraPCMArgsArrayID, bridgingHeaderFileID, sourceFilesArrayID,
|
|
|
|
bridgingSourceFilesArrayID, bridgingModuleDependenciesArrayID,
|
|
|
|
bridgingSourceFilesArrayID, bridgingModuleDependenciesArrayID,
|
|
|
|
CASFileSystemRootID,
|
|
|
|
CASFileSystemRootID,
|
|
|
|
@@ -514,16 +557,15 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
llvm::report_fatal_error(
|
|
|
|
llvm::report_fatal_error(
|
|
|
|
"Unexpected SWIFT_BINARY_MODULE_DETAILS_NODE record");
|
|
|
|
"Unexpected SWIFT_BINARY_MODULE_DETAILS_NODE record");
|
|
|
|
unsigned compiledModulePathID, moduleDocPathID, moduleSourceInfoPathID,
|
|
|
|
unsigned compiledModulePathID, moduleDocPathID, moduleSourceInfoPathID,
|
|
|
|
headerImportID,
|
|
|
|
headerImportID, definingInterfacePathID,
|
|
|
|
headerModuleDependenciesArrayID,
|
|
|
|
headerModuleDependenciesArrayID,
|
|
|
|
headerImportsSourceFilesArrayID, isFramework, isStatic,
|
|
|
|
headerImportsSourceFilesArrayID, isFramework, isStatic,
|
|
|
|
moduleCacheKeyID, userModuleVersionID;
|
|
|
|
moduleCacheKeyID, userModuleVersionID;
|
|
|
|
SwiftBinaryModuleDetailsLayout::readRecord(
|
|
|
|
SwiftBinaryModuleDetailsLayout::readRecord(
|
|
|
|
Scratch, compiledModulePathID, moduleDocPathID,
|
|
|
|
Scratch, compiledModulePathID, moduleDocPathID,
|
|
|
|
moduleSourceInfoPathID,
|
|
|
|
moduleSourceInfoPathID, headerImportID, definingInterfacePathID,
|
|
|
|
headerImportID, headerModuleDependenciesArrayID,
|
|
|
|
headerModuleDependenciesArrayID, headerImportsSourceFilesArrayID,
|
|
|
|
headerImportsSourceFilesArrayID, isFramework, isStatic,
|
|
|
|
isFramework, isStatic, moduleCacheKeyID, userModuleVersionID);
|
|
|
|
moduleCacheKeyID, userModuleVersionID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto compiledModulePath = getIdentifier(compiledModulePathID);
|
|
|
|
auto compiledModulePath = getIdentifier(compiledModulePathID);
|
|
|
|
if (!compiledModulePath)
|
|
|
|
if (!compiledModulePath)
|
|
|
|
@@ -543,13 +585,16 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
auto headerImport = getIdentifier(headerImportID);
|
|
|
|
auto headerImport = getIdentifier(headerImportID);
|
|
|
|
if (!headerImport)
|
|
|
|
if (!headerImport)
|
|
|
|
llvm::report_fatal_error("Bad binary direct dependencies: no header import");
|
|
|
|
llvm::report_fatal_error("Bad binary direct dependencies: no header import");
|
|
|
|
|
|
|
|
auto definingInterfacePath = getIdentifier(definingInterfacePathID);
|
|
|
|
|
|
|
|
if (!definingInterfacePath)
|
|
|
|
|
|
|
|
llvm::report_fatal_error("Bad binary direct dependencies: no defining interface path");
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: LinkLibraries, DefiningModulePath
|
|
|
|
|
|
|
|
// Form the dependencies storage object
|
|
|
|
// Form the dependencies storage object
|
|
|
|
auto moduleDep = ModuleDependencyInfo::forSwiftBinaryModule(
|
|
|
|
auto moduleDep = ModuleDependencyInfo::forSwiftBinaryModule(
|
|
|
|
*compiledModulePath, *moduleDocPath, *moduleSourceInfoPath,
|
|
|
|
*compiledModulePath, *moduleDocPath, *moduleSourceInfoPath,
|
|
|
|
currentModuleImports, currentOptionalModuleImports, {},
|
|
|
|
currentModuleImports, currentOptionalModuleImports, linkLibraries,
|
|
|
|
*headerImport, "", isFramework, isStatic, *moduleCacheKey, *userModuleVersion);
|
|
|
|
*headerImport, *definingInterfacePath, isFramework, isStatic,
|
|
|
|
|
|
|
|
*moduleCacheKey, *userModuleVersion);
|
|
|
|
|
|
|
|
|
|
|
|
// Add imports of this module
|
|
|
|
// Add imports of this module
|
|
|
|
for (const auto &moduleName : currentModuleImports)
|
|
|
|
for (const auto &moduleName : currentModuleImports)
|
|
|
|
@@ -665,11 +710,10 @@ bool ModuleDependenciesCacheDeserializer::readGraph(ModuleDependenciesCache &cac
|
|
|
|
if (!moduleCacheKey)
|
|
|
|
if (!moduleCacheKey)
|
|
|
|
llvm::report_fatal_error("Bad moduleCacheKey");
|
|
|
|
llvm::report_fatal_error("Bad moduleCacheKey");
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: LinkLibraries
|
|
|
|
|
|
|
|
// Form the dependencies storage object
|
|
|
|
// Form the dependencies storage object
|
|
|
|
auto moduleDep = ModuleDependencyInfo::forClangModule(
|
|
|
|
auto moduleDep = ModuleDependencyInfo::forClangModule(
|
|
|
|
*pcmOutputPath, *mappedPCMPath, *moduleMapPath, *contextHash,
|
|
|
|
*pcmOutputPath, *mappedPCMPath, *moduleMapPath, *contextHash,
|
|
|
|
*commandLineArgs, *fileDependencies, *capturedPCMArgs, {},
|
|
|
|
*commandLineArgs, *fileDependencies, *capturedPCMArgs, linkLibraries,
|
|
|
|
*rootFileSystemID, *clangIncludeTreeRoot, *moduleCacheKey, isSystem);
|
|
|
|
*rootFileSystemID, *clangIncludeTreeRoot, *moduleCacheKey, isSystem);
|
|
|
|
|
|
|
|
|
|
|
|
// Add imports of this module
|
|
|
|
// Add imports of this module
|
|
|
|
@@ -747,6 +791,27 @@ ModuleDependenciesCacheDeserializer::getStringArray(unsigned n) {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::optional<std::vector<LinkLibrary>>
|
|
|
|
|
|
|
|
ModuleDependenciesCacheDeserializer::getLinkLibraryArray(unsigned n) {
|
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
|
|
|
|
return std::vector<LinkLibrary>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--n;
|
|
|
|
|
|
|
|
if (n >= ArraysOfLinkLibraryIDs.size())
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto &llIDs = ArraysOfLinkLibraryIDs[n];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto IDtoLLMap = [this](unsigned index) {
|
|
|
|
|
|
|
|
return LinkLibraries[index];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<LinkLibrary> result;
|
|
|
|
|
|
|
|
result.reserve(llIDs.size());
|
|
|
|
|
|
|
|
std::transform(llIDs.begin(), llIDs.end(),
|
|
|
|
|
|
|
|
std::back_inserter(result), IDtoLLMap);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::optional<std::vector<ModuleDependencyID>>
|
|
|
|
std::optional<std::vector<ModuleDependencyID>>
|
|
|
|
ModuleDependenciesCacheDeserializer::getModuleDependencyIDArray(unsigned n) {
|
|
|
|
ModuleDependenciesCacheDeserializer::getModuleDependencyIDArray(unsigned n) {
|
|
|
|
auto encodedIdentifierStringArray = getStringArray(n);
|
|
|
|
auto encodedIdentifierStringArray = getStringArray(n);
|
|
|
|
@@ -806,7 +871,6 @@ enum ModuleIdentifierArrayKind : uint8_t {
|
|
|
|
Empty = 0,
|
|
|
|
Empty = 0,
|
|
|
|
DependencyImports,
|
|
|
|
DependencyImports,
|
|
|
|
OptionalDependencyImports,
|
|
|
|
OptionalDependencyImports,
|
|
|
|
DependencyHeaders,
|
|
|
|
|
|
|
|
ImportedSwiftDependenciesIDs,
|
|
|
|
ImportedSwiftDependenciesIDs,
|
|
|
|
ImportedClangDependenciesIDs,
|
|
|
|
ImportedClangDependenciesIDs,
|
|
|
|
CrossImportOverlayDependenciesIDs,
|
|
|
|
CrossImportOverlayDependenciesIDs,
|
|
|
|
@@ -858,12 +922,16 @@ class ModuleDependenciesCacheSerializer {
|
|
|
|
llvm::StringMap<unsigned, llvm::BumpPtrAllocator> IdentifierIDs;
|
|
|
|
llvm::StringMap<unsigned, llvm::BumpPtrAllocator> IdentifierIDs;
|
|
|
|
std::unordered_map<ModuleDependencyID,
|
|
|
|
std::unordered_map<ModuleDependencyID,
|
|
|
|
llvm::DenseMap<ModuleIdentifierArrayKind, unsigned>>
|
|
|
|
llvm::DenseMap<ModuleIdentifierArrayKind, unsigned>>
|
|
|
|
ArrayIDs;
|
|
|
|
IdentifierArrayIDsMap;
|
|
|
|
unsigned LastIdentifierID = 0;
|
|
|
|
unsigned LastIdentifierID = 0;
|
|
|
|
unsigned LastArrayID = 0;
|
|
|
|
unsigned LastIdentifierArrayID = 0;
|
|
|
|
std::vector<StringRef> Identifiers;
|
|
|
|
std::vector<StringRef> Identifiers;
|
|
|
|
std::vector<std::vector<unsigned>> ArraysOfIdentifiers;
|
|
|
|
std::vector<std::vector<unsigned>> ArraysOfIdentifiers;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::unordered_map<ModuleDependencyID,
|
|
|
|
|
|
|
|
unsigned>
|
|
|
|
|
|
|
|
LinkLibraryArrayIDsMap;
|
|
|
|
|
|
|
|
|
|
|
|
llvm::BitstreamWriter &Out;
|
|
|
|
llvm::BitstreamWriter &Out;
|
|
|
|
|
|
|
|
|
|
|
|
/// A reusable buffer for emitting records.
|
|
|
|
/// A reusable buffer for emitting records.
|
|
|
|
@@ -882,8 +950,9 @@ class ModuleDependenciesCacheSerializer {
|
|
|
|
void addDependencyIDArray(ModuleDependencyID moduleID,
|
|
|
|
void addDependencyIDArray(ModuleDependencyID moduleID,
|
|
|
|
ModuleIdentifierArrayKind arrayKind,
|
|
|
|
ModuleIdentifierArrayKind arrayKind,
|
|
|
|
const ArrayRef<ModuleDependencyID> vec);
|
|
|
|
const ArrayRef<ModuleDependencyID> vec);
|
|
|
|
unsigned getArrayID(ModuleDependencyID moduleID,
|
|
|
|
unsigned getIdentifierArrayID(ModuleDependencyID moduleID,
|
|
|
|
ModuleIdentifierArrayKind arrayKind) const;
|
|
|
|
ModuleIdentifierArrayKind arrayKind) const;
|
|
|
|
|
|
|
|
unsigned getLinkLibrariesArrayID(ModuleDependencyID moduleID) const;
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Layout>
|
|
|
|
template <typename Layout>
|
|
|
|
void registerRecordAbbr() {
|
|
|
|
void registerRecordAbbr() {
|
|
|
|
@@ -908,6 +977,11 @@ class ModuleDependenciesCacheSerializer {
|
|
|
|
void writeIdentifiers();
|
|
|
|
void writeIdentifiers();
|
|
|
|
void writeArraysOfIdentifiers();
|
|
|
|
void writeArraysOfIdentifiers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void writeLinkLibraries(const ModuleDependenciesCache &cache);
|
|
|
|
|
|
|
|
unsigned writeLinkLibraryInfos(ModuleDependencyID moduleID,
|
|
|
|
|
|
|
|
const ModuleDependencyInfo &dependencyInfo);
|
|
|
|
|
|
|
|
void writeLinkLibraryInfoArray(unsigned startIndex, unsigned count);
|
|
|
|
|
|
|
|
|
|
|
|
void writeModuleInfo(ModuleDependencyID moduleID,
|
|
|
|
void writeModuleInfo(ModuleDependencyID moduleID,
|
|
|
|
const ModuleDependencyInfo &dependencyInfo);
|
|
|
|
const ModuleDependencyInfo &dependencyInfo);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -958,6 +1032,8 @@ void ModuleDependenciesCacheSerializer::writeBlockInfoBlock() {
|
|
|
|
BLOCK_RECORD(graph_block, IDENTIFIER_NODE);
|
|
|
|
BLOCK_RECORD(graph_block, IDENTIFIER_NODE);
|
|
|
|
BLOCK_RECORD(graph_block, IDENTIFIER_ARRAY_NODE);
|
|
|
|
BLOCK_RECORD(graph_block, IDENTIFIER_ARRAY_NODE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BLOCK_RECORD(graph_block, LINK_LIBRARY_NODE);
|
|
|
|
|
|
|
|
BLOCK_RECORD(graph_block, LINK_LIBRARY_ARRAY_NODE);
|
|
|
|
BLOCK_RECORD(graph_block, MODULE_NODE);
|
|
|
|
BLOCK_RECORD(graph_block, MODULE_NODE);
|
|
|
|
BLOCK_RECORD(graph_block, SWIFT_INTERFACE_MODULE_DETAILS_NODE);
|
|
|
|
BLOCK_RECORD(graph_block, SWIFT_INTERFACE_MODULE_DETAILS_NODE);
|
|
|
|
BLOCK_RECORD(graph_block, SWIFT_SOURCE_MODULE_DETAILS_NODE);
|
|
|
|
BLOCK_RECORD(graph_block, SWIFT_SOURCE_MODULE_DETAILS_NODE);
|
|
|
|
@@ -997,24 +1073,77 @@ void ModuleDependenciesCacheSerializer::writeArraysOfIdentifiers() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ModuleDependenciesCacheSerializer::writeLinkLibraries(const ModuleDependenciesCache &cache) {
|
|
|
|
|
|
|
|
unsigned lastLLIndex = 0;
|
|
|
|
|
|
|
|
std::map<ModuleDependencyID, std::pair<unsigned, unsigned>> moduleLLArrayMap;
|
|
|
|
|
|
|
|
for (auto kind = ModuleDependencyKind::FirstKind;
|
|
|
|
|
|
|
|
kind != ModuleDependencyKind::LastKind; ++kind) {
|
|
|
|
|
|
|
|
auto modMap = cache.getDependenciesMap(kind);
|
|
|
|
|
|
|
|
for (const auto &entry : modMap) {
|
|
|
|
|
|
|
|
ModuleDependencyID moduleID = {entry.getKey().str(), kind};
|
|
|
|
|
|
|
|
auto optionalDependencyInfo = cache.findDependency(moduleID);
|
|
|
|
|
|
|
|
assert(optionalDependencyInfo.has_value() && "Expected dependency info.");
|
|
|
|
|
|
|
|
auto dependencyInfo = optionalDependencyInfo.value();
|
|
|
|
|
|
|
|
unsigned numLLs = writeLinkLibraryInfos(moduleID, *dependencyInfo);
|
|
|
|
|
|
|
|
moduleLLArrayMap.insert({moduleID, std::make_pair(lastLLIndex, numLLs)});
|
|
|
|
|
|
|
|
lastLLIndex += numLLs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned lastLLArrayIndex = 1;
|
|
|
|
|
|
|
|
for (auto kind = ModuleDependencyKind::FirstKind;
|
|
|
|
|
|
|
|
kind != ModuleDependencyKind::LastKind; ++kind) {
|
|
|
|
|
|
|
|
auto modMap = cache.getDependenciesMap(kind);
|
|
|
|
|
|
|
|
for (const auto &entry : modMap) {
|
|
|
|
|
|
|
|
ModuleDependencyID moduleID = {entry.getKey().str(), kind};
|
|
|
|
|
|
|
|
auto entries = moduleLLArrayMap.at(moduleID);
|
|
|
|
|
|
|
|
if (entries.second == 0)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
writeLinkLibraryInfoArray(entries.first, entries.second);
|
|
|
|
|
|
|
|
LinkLibraryArrayIDsMap.insert({moduleID, lastLLArrayIndex++});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned ModuleDependenciesCacheSerializer::writeLinkLibraryInfos(
|
|
|
|
|
|
|
|
ModuleDependencyID moduleID,
|
|
|
|
|
|
|
|
const ModuleDependencyInfo &dependencyInfo) {
|
|
|
|
|
|
|
|
using namespace graph_block;
|
|
|
|
|
|
|
|
for (auto &linkLibrary : dependencyInfo.getLinkLibraries()) {
|
|
|
|
|
|
|
|
LinkLibraryLayout::emitRecord(Out, ScratchRecord, AbbrCodes[LinkLibraryLayout::Code],
|
|
|
|
|
|
|
|
getIdentifier(linkLibrary.getName().str()),
|
|
|
|
|
|
|
|
linkLibrary.getKind() == LibraryKind::Framework,
|
|
|
|
|
|
|
|
linkLibrary.shouldForceLoad());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return dependencyInfo.getLinkLibraries().size();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ModuleDependenciesCacheSerializer::writeLinkLibraryInfoArray(
|
|
|
|
|
|
|
|
unsigned startIndex, unsigned count) {
|
|
|
|
|
|
|
|
using namespace graph_block;
|
|
|
|
|
|
|
|
std::vector<unsigned> vec(count);
|
|
|
|
|
|
|
|
std::iota(vec.begin(), vec.end(), startIndex);
|
|
|
|
|
|
|
|
LinkLibraryArrayLayout::emitRecord(
|
|
|
|
|
|
|
|
Out, ScratchRecord, AbbrCodes[LinkLibraryArrayLayout::Code], vec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModuleDependenciesCacheSerializer::writeModuleInfo(
|
|
|
|
void ModuleDependenciesCacheSerializer::writeModuleInfo(
|
|
|
|
ModuleDependencyID moduleID,
|
|
|
|
ModuleDependencyID moduleID,
|
|
|
|
const ModuleDependencyInfo &dependencyInfo) {
|
|
|
|
const ModuleDependencyInfo &dependencyInfo) {
|
|
|
|
using namespace graph_block;
|
|
|
|
using namespace graph_block;
|
|
|
|
// TODO: Eliminate per-module context hash
|
|
|
|
|
|
|
|
auto contextHashStrID = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ModuleInfoLayout::emitRecord(
|
|
|
|
ModuleInfoLayout::emitRecord(
|
|
|
|
Out, ScratchRecord, AbbrCodes[ModuleInfoLayout::Code],
|
|
|
|
Out, ScratchRecord, AbbrCodes[ModuleInfoLayout::Code],
|
|
|
|
getIdentifier(moduleID.ModuleName), contextHashStrID,
|
|
|
|
getIdentifier(moduleID.ModuleName),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::DependencyImports),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::DependencyImports),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::OptionalDependencyImports),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::OptionalDependencyImports),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::ImportedSwiftDependenciesIDs),
|
|
|
|
getLinkLibrariesArrayID(moduleID),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::ImportedClangDependenciesIDs),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::ImportedSwiftDependenciesIDs),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::CrossImportOverlayDependenciesIDs),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::ImportedClangDependenciesIDs),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::SwiftOverlayDependenciesIDs),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::CrossImportOverlayDependenciesIDs),
|
|
|
|
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::SwiftOverlayDependenciesIDs),
|
|
|
|
getIdentifier(dependencyInfo.getModuleCacheKey()),
|
|
|
|
getIdentifier(dependencyInfo.getModuleCacheKey()),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::AuxiliaryFileIDs));
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::AuxiliaryFileIDs));
|
|
|
|
|
|
|
|
|
|
|
|
switch (dependencyInfo.getKind()) {
|
|
|
|
switch (dependencyInfo.getKind()) {
|
|
|
|
case swift::ModuleDependencyKind::SwiftInterface: {
|
|
|
|
case swift::ModuleDependencyKind::SwiftInterface: {
|
|
|
|
@@ -1032,16 +1161,16 @@ void ModuleDependenciesCacheSerializer::writeModuleInfo(
|
|
|
|
SwiftInterfaceModuleDetailsLayout::emitRecord(
|
|
|
|
SwiftInterfaceModuleDetailsLayout::emitRecord(
|
|
|
|
Out, ScratchRecord, AbbrCodes[SwiftInterfaceModuleDetailsLayout::Code],
|
|
|
|
Out, ScratchRecord, AbbrCodes[SwiftInterfaceModuleDetailsLayout::Code],
|
|
|
|
outputModulePathFileId, swiftInterfaceFileId,
|
|
|
|
outputModulePathFileId, swiftInterfaceFileId,
|
|
|
|
getArrayID(moduleID,
|
|
|
|
getIdentifierArrayID(moduleID,
|
|
|
|
ModuleIdentifierArrayKind::CompiledModuleCandidates),
|
|
|
|
ModuleIdentifierArrayKind::CompiledModuleCandidates),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::BuildCommandLine),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::BuildCommandLine),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs),
|
|
|
|
getIdentifier(swiftTextDeps->contextHash),
|
|
|
|
getIdentifier(swiftTextDeps->contextHash),
|
|
|
|
swiftTextDeps->isFramework, swiftTextDeps->isStatic,
|
|
|
|
swiftTextDeps->isFramework, swiftTextDeps->isStatic,
|
|
|
|
bridgingHeaderFileId,
|
|
|
|
bridgingHeaderFileId,
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::SourceFiles),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::SourceFiles),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles),
|
|
|
|
getArrayID(moduleID,
|
|
|
|
getIdentifierArrayID(moduleID,
|
|
|
|
ModuleIdentifierArrayKind::BridgingModuleDependencies),
|
|
|
|
ModuleIdentifierArrayKind::BridgingModuleDependencies),
|
|
|
|
getIdentifier(swiftTextDeps->textualModuleDetails.CASFileSystemRootID),
|
|
|
|
getIdentifier(swiftTextDeps->textualModuleDetails.CASFileSystemRootID),
|
|
|
|
getIdentifier(swiftTextDeps->textualModuleDetails
|
|
|
|
getIdentifier(swiftTextDeps->textualModuleDetails
|
|
|
|
@@ -1060,18 +1189,18 @@ void ModuleDependenciesCacheSerializer::writeModuleInfo(
|
|
|
|
: 0;
|
|
|
|
: 0;
|
|
|
|
SwiftSourceModuleDetailsLayout::emitRecord(
|
|
|
|
SwiftSourceModuleDetailsLayout::emitRecord(
|
|
|
|
Out, ScratchRecord, AbbrCodes[SwiftSourceModuleDetailsLayout::Code],
|
|
|
|
Out, ScratchRecord, AbbrCodes[SwiftSourceModuleDetailsLayout::Code],
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs),
|
|
|
|
bridgingHeaderFileId,
|
|
|
|
bridgingHeaderFileId,
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::SourceFiles),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::SourceFiles),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles),
|
|
|
|
getArrayID(moduleID,
|
|
|
|
getIdentifierArrayID(moduleID,
|
|
|
|
ModuleIdentifierArrayKind::BridgingModuleDependencies),
|
|
|
|
ModuleIdentifierArrayKind::BridgingModuleDependencies),
|
|
|
|
getIdentifier(
|
|
|
|
getIdentifier(
|
|
|
|
swiftSourceDeps->textualModuleDetails.CASFileSystemRootID),
|
|
|
|
swiftSourceDeps->textualModuleDetails.CASFileSystemRootID),
|
|
|
|
getIdentifier(swiftSourceDeps->textualModuleDetails
|
|
|
|
getIdentifier(swiftSourceDeps->textualModuleDetails
|
|
|
|
.CASBridgingHeaderIncludeTreeRootID),
|
|
|
|
.CASBridgingHeaderIncludeTreeRootID),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::BuildCommandLine),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::BuildCommandLine),
|
|
|
|
getArrayID(moduleID,
|
|
|
|
getIdentifierArrayID(moduleID,
|
|
|
|
ModuleIdentifierArrayKind::BridgingHeaderBuildCommandLine));
|
|
|
|
ModuleIdentifierArrayKind::BridgingHeaderBuildCommandLine));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1083,9 +1212,10 @@ void ModuleDependenciesCacheSerializer::writeModuleInfo(
|
|
|
|
getIdentifier(swiftBinDeps->compiledModulePath),
|
|
|
|
getIdentifier(swiftBinDeps->compiledModulePath),
|
|
|
|
getIdentifier(swiftBinDeps->moduleDocPath),
|
|
|
|
getIdentifier(swiftBinDeps->moduleDocPath),
|
|
|
|
getIdentifier(swiftBinDeps->sourceInfoPath),
|
|
|
|
getIdentifier(swiftBinDeps->sourceInfoPath),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::DependencyHeaders),
|
|
|
|
getIdentifier(swiftBinDeps->headerImport),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::HeaderInputModuleDependencies),
|
|
|
|
getIdentifier(swiftBinDeps->definingModuleInterfacePath),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::HeaderInputDependencySourceFiles),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::HeaderInputModuleDependencies),
|
|
|
|
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::HeaderInputDependencySourceFiles),
|
|
|
|
swiftBinDeps->isFramework, swiftBinDeps->isStatic,
|
|
|
|
swiftBinDeps->isFramework, swiftBinDeps->isStatic,
|
|
|
|
getIdentifier(swiftBinDeps->moduleCacheKey),
|
|
|
|
getIdentifier(swiftBinDeps->moduleCacheKey),
|
|
|
|
getIdentifier(swiftBinDeps->userModuleVersion));
|
|
|
|
getIdentifier(swiftBinDeps->userModuleVersion));
|
|
|
|
@@ -1112,9 +1242,9 @@ void ModuleDependenciesCacheSerializer::writeModuleInfo(
|
|
|
|
getIdentifier(clangDeps->mappedPCMPath),
|
|
|
|
getIdentifier(clangDeps->mappedPCMPath),
|
|
|
|
getIdentifier(clangDeps->moduleMapFile),
|
|
|
|
getIdentifier(clangDeps->moduleMapFile),
|
|
|
|
getIdentifier(clangDeps->contextHash),
|
|
|
|
getIdentifier(clangDeps->contextHash),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::NonPathCommandLine),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::NonPathCommandLine),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::FileDependencies),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::FileDependencies),
|
|
|
|
getArrayID(moduleID, ModuleIdentifierArrayKind::CapturedPCMArgs),
|
|
|
|
getIdentifierArrayID(moduleID, ModuleIdentifierArrayKind::CapturedPCMArgs),
|
|
|
|
getIdentifier(clangDeps->CASFileSystemRootID),
|
|
|
|
getIdentifier(clangDeps->CASFileSystemRootID),
|
|
|
|
getIdentifier(clangDeps->CASClangIncludeTreeRootID),
|
|
|
|
getIdentifier(clangDeps->CASClangIncludeTreeRootID),
|
|
|
|
getIdentifier(clangDeps->moduleCacheKey), clangDeps->IsSystem);
|
|
|
|
getIdentifier(clangDeps->moduleCacheKey), clangDeps->IsSystem);
|
|
|
|
@@ -1166,21 +1296,21 @@ void ModuleDependenciesCacheSerializer::addDependencyIDArray(ModuleDependencyID
|
|
|
|
void ModuleDependenciesCacheSerializer::addStringArray(ModuleDependencyID moduleID,
|
|
|
|
void ModuleDependenciesCacheSerializer::addStringArray(ModuleDependencyID moduleID,
|
|
|
|
ModuleIdentifierArrayKind arrayKind,
|
|
|
|
ModuleIdentifierArrayKind arrayKind,
|
|
|
|
const std::vector<std::string> &vec) {
|
|
|
|
const std::vector<std::string> &vec) {
|
|
|
|
if (ArrayIDs.find(moduleID) != ArrayIDs.end()) {
|
|
|
|
if (IdentifierArrayIDsMap.find(moduleID) != IdentifierArrayIDsMap.end()) {
|
|
|
|
// Already have arrays for this module
|
|
|
|
// Already have arrays for this module
|
|
|
|
llvm::DenseMap<ModuleIdentifierArrayKind, unsigned>::iterator iter;
|
|
|
|
llvm::DenseMap<ModuleIdentifierArrayKind, unsigned>::iterator iter;
|
|
|
|
bool isNew;
|
|
|
|
bool isNew;
|
|
|
|
std::tie(iter, isNew) =
|
|
|
|
std::tie(iter, isNew) =
|
|
|
|
ArrayIDs[moduleID].insert({arrayKind, LastArrayID + 1});
|
|
|
|
IdentifierArrayIDsMap[moduleID].insert({arrayKind, LastIdentifierArrayID + 1});
|
|
|
|
if (!isNew)
|
|
|
|
if (!isNew)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Do not yet have any arrays for this module
|
|
|
|
// Do not yet have any arrays for this module
|
|
|
|
ArrayIDs[moduleID] = llvm::DenseMap<ModuleIdentifierArrayKind, unsigned>();
|
|
|
|
IdentifierArrayIDsMap[moduleID] = llvm::DenseMap<ModuleIdentifierArrayKind, unsigned>();
|
|
|
|
ArrayIDs[moduleID].insert({arrayKind, LastArrayID + 1});
|
|
|
|
IdentifierArrayIDsMap[moduleID].insert({arrayKind, LastIdentifierArrayID + 1});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
++LastArrayID;
|
|
|
|
++LastIdentifierArrayID;
|
|
|
|
|
|
|
|
|
|
|
|
// Add in the individual identifiers in the array
|
|
|
|
// Add in the individual identifiers in the array
|
|
|
|
std::vector<unsigned> identifierIDs;
|
|
|
|
std::vector<unsigned> identifierIDs;
|
|
|
|
@@ -1193,24 +1323,33 @@ void ModuleDependenciesCacheSerializer::addStringArray(ModuleDependencyID module
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned ModuleDependenciesCacheSerializer::getArrayID(ModuleDependencyID moduleID,
|
|
|
|
unsigned ModuleDependenciesCacheSerializer::getIdentifierArrayID(ModuleDependencyID moduleID,
|
|
|
|
ModuleIdentifierArrayKind arrayKind) const {
|
|
|
|
ModuleIdentifierArrayKind arrayKind) const {
|
|
|
|
auto iter = ArrayIDs.find(moduleID);
|
|
|
|
auto iter = IdentifierArrayIDsMap.find(moduleID);
|
|
|
|
assert(iter != ArrayIDs.end());
|
|
|
|
assert(iter != IdentifierArrayIDsMap.end());
|
|
|
|
auto &innerMap = iter->second;
|
|
|
|
auto &innerMap = iter->second;
|
|
|
|
auto arrayIter = innerMap.find(arrayKind);
|
|
|
|
auto arrayIter = innerMap.find(arrayKind);
|
|
|
|
assert(arrayIter != innerMap.end());
|
|
|
|
assert(arrayIter != innerMap.end());
|
|
|
|
return arrayIter->second;
|
|
|
|
return arrayIter->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned ModuleDependenciesCacheSerializer::getLinkLibrariesArrayID(ModuleDependencyID moduleID) const {
|
|
|
|
|
|
|
|
auto iter = LinkLibraryArrayIDsMap.find(moduleID);
|
|
|
|
|
|
|
|
if (iter == LinkLibraryArrayIDsMap.end())
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return iter->second;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
|
|
|
void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
|
|
|
const ModuleDependenciesCache &cache) {
|
|
|
|
const ModuleDependenciesCache &cache) {
|
|
|
|
addIdentifier(cache.scannerContextHash);
|
|
|
|
addIdentifier(cache.scannerContextHash);
|
|
|
|
// TODO: Serialize *all* modules
|
|
|
|
for (auto kind = ModuleDependencyKind::FirstKind;
|
|
|
|
for (auto &moduleID : cache.getAllDependencies({cache.mainScanModuleName,
|
|
|
|
kind != ModuleDependencyKind::LastKind; ++kind) {
|
|
|
|
ModuleDependencyKind::SwiftSource})) {
|
|
|
|
auto modMap = cache.getDependenciesMap(kind);
|
|
|
|
auto optionalDependencyInfo =
|
|
|
|
for (const auto &entry : modMap) {
|
|
|
|
cache.findDependency(moduleID.ModuleName, moduleID.Kind);
|
|
|
|
ModuleDependencyID moduleID = {entry.getKey().str(), kind};
|
|
|
|
|
|
|
|
auto optionalDependencyInfo = cache.findDependency(moduleID);
|
|
|
|
assert(optionalDependencyInfo.has_value() && "Expected dependency info.");
|
|
|
|
assert(optionalDependencyInfo.has_value() && "Expected dependency info.");
|
|
|
|
auto dependencyInfo = optionalDependencyInfo.value();
|
|
|
|
auto dependencyInfo = optionalDependencyInfo.value();
|
|
|
|
// Add the module's name
|
|
|
|
// Add the module's name
|
|
|
|
@@ -1222,7 +1361,10 @@ void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
|
|
|
return importInfo.importIdentifier;
|
|
|
|
return importInfo.importIdentifier;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Add the module's dependencies
|
|
|
|
for (const auto &ll : dependencyInfo->getLinkLibraries())
|
|
|
|
|
|
|
|
addIdentifier(ll.getName().str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add the module's imports
|
|
|
|
std::vector<std::string> importIdentifiers;
|
|
|
|
std::vector<std::string> importIdentifiers;
|
|
|
|
llvm::transform(dependencyInfo->getModuleImports(),
|
|
|
|
llvm::transform(dependencyInfo->getModuleImports(),
|
|
|
|
std::back_inserter(importIdentifiers),
|
|
|
|
std::back_inserter(importIdentifiers),
|
|
|
|
@@ -1237,28 +1379,21 @@ void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
|
|
|
addStringArray(moduleID, ModuleIdentifierArrayKind::OptionalDependencyImports,
|
|
|
|
addStringArray(moduleID, ModuleIdentifierArrayKind::OptionalDependencyImports,
|
|
|
|
optionalImportIdentifiers);
|
|
|
|
optionalImportIdentifiers);
|
|
|
|
|
|
|
|
|
|
|
|
ModuleDependencyIDSetVector allDependencies;
|
|
|
|
addDependencyIDArray(moduleID,
|
|
|
|
if (dependencyInfo->isSwiftModule()) {
|
|
|
|
ModuleIdentifierArrayKind::ImportedSwiftDependenciesIDs,
|
|
|
|
auto swiftImportedDepsRef = dependencyInfo->getImportedSwiftDependencies();
|
|
|
|
dependencyInfo->getImportedSwiftDependencies());
|
|
|
|
auto headerClangDepsRef = dependencyInfo->getHeaderClangDependencies();
|
|
|
|
addDependencyIDArray(moduleID,
|
|
|
|
auto overlayDependenciesRef = dependencyInfo->getSwiftOverlayDependencies();
|
|
|
|
ModuleIdentifierArrayKind::ImportedClangDependenciesIDs,
|
|
|
|
allDependencies.insert(swiftImportedDepsRef.begin(),
|
|
|
|
dependencyInfo->getImportedClangDependencies());
|
|
|
|
swiftImportedDepsRef.end());
|
|
|
|
addDependencyIDArray(moduleID,
|
|
|
|
allDependencies.insert(headerClangDepsRef.begin(),
|
|
|
|
ModuleIdentifierArrayKind::CrossImportOverlayDependenciesIDs,
|
|
|
|
headerClangDepsRef.end());
|
|
|
|
dependencyInfo->getCrossImportOverlayDependencies());
|
|
|
|
allDependencies.insert(overlayDependenciesRef.begin(),
|
|
|
|
addDependencyIDArray(moduleID,
|
|
|
|
overlayDependenciesRef.end());
|
|
|
|
ModuleIdentifierArrayKind::SwiftOverlayDependenciesIDs,
|
|
|
|
}
|
|
|
|
dependencyInfo->getSwiftOverlayDependencies());
|
|
|
|
|
|
|
|
|
|
|
|
if (dependencyInfo->isSwiftSourceModule()) {
|
|
|
|
addStringArray(moduleID, ModuleIdentifierArrayKind::AuxiliaryFileIDs,
|
|
|
|
auto crossImportOverlayDepsRef = dependencyInfo->getCrossImportOverlayDependencies();
|
|
|
|
dependencyInfo->getAuxiliaryFiles());
|
|
|
|
allDependencies.insert(crossImportOverlayDepsRef.begin(),
|
|
|
|
|
|
|
|
crossImportOverlayDepsRef.end());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto clangImportedDepsRef = dependencyInfo->getImportedClangDependencies();
|
|
|
|
|
|
|
|
allDependencies.insert(clangImportedDepsRef.begin(),
|
|
|
|
|
|
|
|
clangImportedDepsRef.end());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> clangHeaderDependencyNames;
|
|
|
|
std::vector<std::string> clangHeaderDependencyNames;
|
|
|
|
for (const auto &headerDepID :
|
|
|
|
for (const auto &headerDepID :
|
|
|
|
@@ -1304,6 +1439,7 @@ void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
|
|
|
addIdentifier(swiftBinDeps->sourceInfoPath);
|
|
|
|
addIdentifier(swiftBinDeps->sourceInfoPath);
|
|
|
|
addIdentifier(swiftBinDeps->moduleCacheKey);
|
|
|
|
addIdentifier(swiftBinDeps->moduleCacheKey);
|
|
|
|
addIdentifier(swiftBinDeps->headerImport);
|
|
|
|
addIdentifier(swiftBinDeps->headerImport);
|
|
|
|
|
|
|
|
addIdentifier(swiftBinDeps->userModuleVersion);
|
|
|
|
addStringArray(moduleID, ModuleIdentifierArrayKind::HeaderInputModuleDependencies,
|
|
|
|
addStringArray(moduleID, ModuleIdentifierArrayKind::HeaderInputModuleDependencies,
|
|
|
|
clangHeaderDependencyNames);
|
|
|
|
clangHeaderDependencyNames);
|
|
|
|
addStringArray(moduleID, ModuleIdentifierArrayKind::HeaderInputDependencySourceFiles,
|
|
|
|
addStringArray(moduleID, ModuleIdentifierArrayKind::HeaderInputDependencySourceFiles,
|
|
|
|
@@ -1367,6 +1503,7 @@ void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
|
|
|
llvm_unreachable("Unhandled dependency kind.");
|
|
|
|
llvm_unreachable("Unhandled dependency kind.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModuleDependenciesCacheSerializer::writeInterModuleDependenciesCache(
|
|
|
|
void ModuleDependenciesCacheSerializer::writeInterModuleDependenciesCache(
|
|
|
|
@@ -1385,8 +1522,9 @@ void ModuleDependenciesCacheSerializer::writeInterModuleDependenciesCache(
|
|
|
|
registerRecordAbbr<IdentifierNodeLayout>();
|
|
|
|
registerRecordAbbr<IdentifierNodeLayout>();
|
|
|
|
registerRecordAbbr<IdentifierArrayLayout>();
|
|
|
|
registerRecordAbbr<IdentifierArrayLayout>();
|
|
|
|
registerRecordAbbr<LinkLibraryLayout>();
|
|
|
|
registerRecordAbbr<LinkLibraryLayout>();
|
|
|
|
registerRecordAbbr<SourceLocationLayout>();
|
|
|
|
registerRecordAbbr<LinkLibraryArrayLayout>();
|
|
|
|
registerRecordAbbr<ImportStatementLayout>();
|
|
|
|
// registerRecordAbbr<SourceLocationLayout>();
|
|
|
|
|
|
|
|
// registerRecordAbbr<ImportStatementLayout>();
|
|
|
|
registerRecordAbbr<ModuleInfoLayout>();
|
|
|
|
registerRecordAbbr<ModuleInfoLayout>();
|
|
|
|
registerRecordAbbr<SwiftSourceModuleDetailsLayout>();
|
|
|
|
registerRecordAbbr<SwiftSourceModuleDetailsLayout>();
|
|
|
|
registerRecordAbbr<SwiftInterfaceModuleDetailsLayout>();
|
|
|
|
registerRecordAbbr<SwiftInterfaceModuleDetailsLayout>();
|
|
|
|
@@ -1407,13 +1545,16 @@ void ModuleDependenciesCacheSerializer::writeInterModuleDependenciesCache(
|
|
|
|
// Write the arrays
|
|
|
|
// Write the arrays
|
|
|
|
writeArraysOfIdentifiers();
|
|
|
|
writeArraysOfIdentifiers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Write all the arrays of link library infos for this graph
|
|
|
|
|
|
|
|
writeLinkLibraries(cache);
|
|
|
|
|
|
|
|
|
|
|
|
// Write the core graph
|
|
|
|
// Write the core graph
|
|
|
|
// TODO: Serialize *all* modules
|
|
|
|
for (auto kind = ModuleDependencyKind::FirstKind;
|
|
|
|
for (auto &moduleID : cache.getAllDependencies({cache.mainScanModuleName,
|
|
|
|
kind != ModuleDependencyKind::LastKind; ++kind) {
|
|
|
|
ModuleDependencyKind::SwiftSource})) {
|
|
|
|
auto modMap = cache.getDependenciesMap(kind);
|
|
|
|
auto dependencyInfo = cache.findDependency(moduleID.ModuleName, moduleID.Kind);
|
|
|
|
for (const auto &modInfo : modMap) {
|
|
|
|
assert(dependencyInfo.has_value() && "Expected dependency info.");
|
|
|
|
writeModuleInfo({modInfo.getKey().str(), kind}, modInfo.second);
|
|
|
|
writeModuleInfo(moduleID, **dependencyInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|