Skip to content

Commit

Permalink
[clang][modules] Avoid unnecessary writes of .timestamp files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jansvoboda11 committed May 10, 2023
1 parent 1a85581 commit 63eb04a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4507,18 +4507,16 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
}
}

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

Expand Down

0 comments on commit 63eb04a

Please sign in to comment.