Skip to content

Commit 830d66d

Browse files
committed
[clang][modules] Avoid unnecessary writes of .timestamp files
Clang currently updates the mtime of .timestamp files on each load of the corresponding .pcm file. This is not necessary. In a given build session, Clang only needs to write the .timestamp file once, when we first validate the input files. This patch makes it so that we only touch the .timestamp file when it's older than the build session, alleviating some filesystem contention in clang-scan-deps. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D149802 (cherry picked from commit 63eb04a)
1 parent 06c4ba1 commit 830d66d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

clang/lib/Serialization/ASTReader.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4474,18 +4474,16 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
44744474
}
44754475
}
44764476

4477-
if (PP.getHeaderSearchInfo()
4478-
.getHeaderSearchOpts()
4479-
.ModulesValidateOncePerBuildSession) {
4477+
HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
4478+
if (HSOpts.ModulesValidateOncePerBuildSession) {
44804479
// Now we are certain that the module and all modules it depends on are
4481-
// up to date. Create or update timestamp files for modules that are
4482-
// located in the module cache (not for PCH files that could be anywhere
4483-
// in the filesystem).
4480+
// up-to-date. For implicitly-built module files, ensure the corresponding
4481+
// timestamp files are up-to-date in this build session.
44844482
for (unsigned I = 0, N = Loaded.size(); I != N; ++I) {
44854483
ImportedModule &M = Loaded[I];
4486-
if (M.Mod->Kind == MK_ImplicitModule) {
4484+
if (M.Mod->Kind == MK_ImplicitModule &&
4485+
M.Mod->InputFilesValidationTimestamp < HSOpts.BuildSessionTimestamp)
44874486
updateModuleTimestamp(*M.Mod);
4488-
}
44894487
}
44904488
}
44914489

0 commit comments

Comments
 (0)