[Dependency Scanning] Include initial PCM arguments on Clang module dependency details

Doing so will allow clients to know which Swift-specific PCM arguments are already captured from the scan that first discovered this module.
SwiftDriver, in particular, will be able to use this information to avoid re-scanning a given Clang module if the initial scan was sufficient for all possible sets of PCM arguments on Swift modules that depend on said Clang module.
This commit is contained in:
Artem Chikin
2021-09-22 11:34:02 -07:00
parent e460a7db84
commit 6176657285
10 changed files with 62 additions and 17 deletions

View File

@@ -447,10 +447,11 @@ bool Deserializer::readGraph(GlobalModuleDependenciesCache &cache) {
llvm::report_fatal_error("Unexpected CLANG_MODULE_DETAILS_NODE record");
cache.configureForTriple(getTriple());
unsigned moduleMapPathID, contextHashID, commandLineArrayID,
fileDependenciesArrayID;
fileDependenciesArrayID, capturedPCMArgsArrayID;
ClangModuleDetailsLayout::readRecord(Scratch, moduleMapPathID,
contextHashID, commandLineArrayID,
fileDependenciesArrayID);
fileDependenciesArrayID,
capturedPCMArgsArrayID);
auto moduleMapPath = getIdentifier(moduleMapPathID);
if (!moduleMapPath)
llvm::report_fatal_error("Bad module map path");
@@ -463,10 +464,15 @@ bool Deserializer::readGraph(GlobalModuleDependenciesCache &cache) {
auto fileDependencies = getArray(fileDependenciesArrayID);
if (!fileDependencies)
llvm::report_fatal_error("Bad file dependencies");
auto capturedPCMArgs = getArray(capturedPCMArgsArrayID);
if (!capturedPCMArgs)
llvm::report_fatal_error("Bad captured PCM Args");
// Form the dependencies storage object
auto moduleDep = ModuleDependencies::forClangModule(
*moduleMapPath, *contextHash, *commandLineArgs, *fileDependencies);
*moduleMapPath, *contextHash, *commandLineArgs, *fileDependencies,
*capturedPCMArgs);
// Add dependencies of this module
for (const auto &moduleName : *currentModuleDependencies)
moduleDep.addModuleDependency(moduleName);
@@ -572,6 +578,7 @@ enum ModuleIdentifierArrayKind : uint8_t {
BridgingModuleDependencies,
NonPathCommandLine,
FileDependencies,
CapturedPCMArgs,
LastArrayKind
};
@@ -846,7 +853,8 @@ void Serializer::writeModuleInfo(ModuleDependencyID moduleID,
getIdentifier(clangDeps->moduleMapFile),
getIdentifier(clangDeps->contextHash),
getArray(moduleID, ModuleIdentifierArrayKind::NonPathCommandLine),
getArray(moduleID, ModuleIdentifierArrayKind::FileDependencies));
getArray(moduleID, ModuleIdentifierArrayKind::FileDependencies),
getArray(moduleID, ModuleIdentifierArrayKind::CapturedPCMArgs));
break;
}
@@ -1015,6 +1023,8 @@ void Serializer::collectStringsAndArrays(
clangDeps->nonPathCommandLine);
addArray(moduleID, ModuleIdentifierArrayKind::FileDependencies,
clangDeps->fileDependencies);
addArray(moduleID, ModuleIdentifierArrayKind::CapturedPCMArgs,
clangDeps->capturedPCMArgs);
break;
}
default: