Skip to content

Commit 63eb04a

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
1 parent 1a85581 commit 63eb04a

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
@@ -4507,18 +4507,16 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
45074507
}
45084508
}
45094509

4510-
if (PP.getHeaderSearchInfo()
4511-
.getHeaderSearchOpts()
4512-
.ModulesValidateOncePerBuildSession) {
4510+
HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
4511+
if (HSOpts.ModulesValidateOncePerBuildSession) {
45134512
// Now we are certain that the module and all modules it depends on are
4514-
// up to date. Create or update timestamp files for modules that are
4515-
// located in the module cache (not for PCH files that could be anywhere
4516-
// in the filesystem).
4513+
// up-to-date. For implicitly-built module files, ensure the corresponding
4514+
// timestamp files are up-to-date in this build session.
45174515
for (unsigned I = 0, N = Loaded.size(); I != N; ++I) {
45184516
ImportedModule &M = Loaded[I];
4519-
if (M.Mod->Kind == MK_ImplicitModule) {
4517+
if (M.Mod->Kind == MK_ImplicitModule &&
4518+
M.Mod->InputFilesValidationTimestamp < HSOpts.BuildSessionTimestamp)
45204519
updateModuleTimestamp(*M.Mod);
4521-
}
45224520
}
45234521
}
45244522

0 commit comments

Comments
 (0)