diff options
author | Rumeet Dhindsa <rdhindsa@google.com> | 2020-03-10 10:59:26 -0700 |
---|---|---|
committer | Rumeet Dhindsa <rdhindsa@google.com> | 2020-03-10 10:59:26 -0700 |
commit | 57a2eaf3c1aa1a08e9b474b873064e075c52daef (patch) | |
tree | 1148ef779729a5cee1a973d70e9ca89fb0fbce3a /clang/lib/Serialization/ModuleManager.cpp | |
parent | 66945b62f42f0911a328a354cbc7db40b05b76eb (diff) | |
download | llvm-57a2eaf3c1aa1a08e9b474b873064e075c52daef.zip llvm-57a2eaf3c1aa1a08e9b474b873064e075c52daef.tar.gz llvm-57a2eaf3c1aa1a08e9b474b873064e075c52daef.tar.bz2 |
Revert "[modules] Do not cache invalid state for modules that we attempted to load."
As per comment on https://reviews.llvm.org/D72860, it is suggested to
revert this change in the meantime, since it has introduced regression.
This reverts commit 83f4c3af021cd5322ea10fd1c4e839874c1dae49.
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
-rw-r--r-- | clang/lib/Serialization/ModuleManager.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index 9b326d2..2656220 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -163,7 +163,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type, // Load the contents of the module if (std::unique_ptr<llvm::MemoryBuffer> Buffer = lookupBuffer(FileName)) { // The buffer was already provided for us. - NewModule->Buffer = &ModuleCache->addFinalPCM(FileName, std::move(Buffer)); + NewModule->Buffer = &ModuleCache->addBuiltPCM(FileName, std::move(Buffer)); // Since the cached buffer is reused, it is safe to close the file // descriptor that was opened while stat()ing the PCM in // lookupModuleFile() above, it won't be needed any longer. @@ -173,6 +173,11 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type, NewModule->Buffer = Buffer; // As above, the file descriptor is no longer needed. Entry->closeFile(); + } else if (getModuleCache().shouldBuildPCM(FileName)) { + // Report that the module is out of date, since we tried (and failed) to + // import it earlier. + Entry->closeFile(); + return OutOfDate; } else { // Open the AST file. llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buf((std::error_code())); @@ -180,9 +185,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type, Buf = llvm::MemoryBuffer::getSTDIN(); } else { // Get a buffer of the file and close the file descriptor when done. - // The file is volatile because in a parallel build we expect multiple - // compiler processes to use the same module file rebuilding it if needed. - Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/true); + Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/false); } if (!Buf) { |