From 1698beb5420f6e6f7eed5d9914ab6a10ff5f4b1f Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 7 May 2025 14:02:40 -0700 Subject: [clang][modules][deps] Optimize in-process timestamping of PCMs (#137363) In the past, timestamps used for `-fmodules-validate-once-per-build-session` were found to be a source of contention in the dependency scanner ([D149802](https://reviews.llvm.org/D149802), https://github.com/llvm/llvm-project/pull/112452). This PR is yet another attempt to optimize these. We now make use of the new `ModuleCache` interface to implement the in-process version in terms of atomic `std::time_t` variables rather the mtime attribute on `.timestamp` files. --- clang/lib/Serialization/ModuleManager.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'clang/lib/Serialization/ModuleManager.cpp') diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index d466ea0..e3d7ff4 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -174,15 +174,9 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type, NewModule->ImportLoc = ImportLoc; NewModule->InputFilesValidationTimestamp = 0; - if (NewModule->Kind == MK_ImplicitModule) { - std::string TimestampFilename = - ModuleFile::getTimestampFilename(NewModule->FileName); - llvm::vfs::Status Status; - // A cached stat value would be fine as well. - if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status)) - NewModule->InputFilesValidationTimestamp = - llvm::sys::toTimeT(Status.getLastModificationTime()); - } + if (NewModule->Kind == MK_ImplicitModule) + NewModule->InputFilesValidationTimestamp = + ModCache->getModuleTimestamp(NewModule->FileName); // Load the contents of the module if (std::unique_ptr Buffer = lookupBuffer(FileName)) { -- cgit v1.1