Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)

* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag

This includes a bit in the module format to represent if the module was
compiled with -enable-ossa-modules flag. When compiling a client module
with -enable-ossa-modules flag, all dependent modules are checked for this bit,
if not on, recompilation is triggered with -enable-ossa-modules.

* Updated tests
This commit is contained in:
Meghana Gupta
2021-10-04 18:46:40 -07:00
committed by GitHub
parent b3416247f5
commit f458d9b490
36 changed files with 213 additions and 173 deletions

View File

@@ -198,8 +198,10 @@ public:
namespace path = llvm::sys::path;
static bool serializedASTLooksValid(const llvm::MemoryBuffer &buf) {
auto VI = serialization::validateSerializedAST(buf.getBuffer());
static bool serializedASTLooksValid(const llvm::MemoryBuffer &buf,
bool requiresOSSAModules) {
auto VI = serialization::validateSerializedAST(buf.getBuffer(),
requiresOSSAModules);
return VI.status == serialization::Status::Valid;
}
@@ -497,7 +499,8 @@ class ModuleInterfaceLoaderImpl {
LLVM_DEBUG(llvm::dbgs() << "Validating deps of " << path << "\n");
auto validationInfo = serialization::validateSerializedAST(
buf.getBuffer(), /*ExtendedValidationInfo=*/nullptr, &allDeps);
buf.getBuffer(), requiresOSSAModules,
/*ExtendedValidationInfo=*/nullptr, &allDeps);
if (validationInfo.status != serialization::Status::Valid) {
rebuildInfo.setSerializationStatus(path, validationInfo.status);
@@ -538,7 +541,7 @@ class ModuleInterfaceLoaderImpl {
// First, make sure the underlying module path exists and is valid.
auto modBuf = fs.getBufferForFile(fwd.underlyingModulePath);
if (!modBuf || !serializedASTLooksValid(*modBuf.get()))
if (!modBuf || !serializedASTLooksValid(*modBuf.get(), requiresOSSAModules))
return false;
// Next, check the dependencies in the forwarding file.
@@ -646,12 +649,6 @@ class ModuleInterfaceLoaderImpl {
}
std::pair<std::string, std::string> getCompiledModuleCandidates() {
// If we require ossa modules, then we /always/ rebuild the module interface
// regardless of the module loading mode.
if (requiresOSSAModules) {
return {};
}
std::pair<std::string, std::string> result;
// Keep track of whether we should attempt to load a .swiftmodule adjacent
// to the .swiftinterface.