vtjnash wrote:
Applying the GPT-proposed fix for that bug would be unrelated to this PR:
```diff
--- a/clang/lib/DependencyScanning/InProcessModuleCache.cpp
+++ b/clang/lib/DependencyScanning/InProcessModuleCache.cpp
@@
void updateModuleTimestamp(StringRef Filename) override {
- // Note: This essentially replaces FS contention with mutex contention.
- auto &Timestamp = getOrCreateEntry(Filename).Timestamp;
-
- Logger.log() << "timestamp_write: " << Filename;
- Timestamp.store(llvm::sys::toTimeT(std::chrono::system_clock::now()));
+ // Note: This essentially replaces FS contention with mutex contention.
+ // Only update/log the timestamp once to avoid duplicate timestamp_write
+ // entries when multiple threads race to validate/build the same module.
+ auto &Entry = getOrCreateEntry(Filename);
+ // Protect access to the entry so that two threads won't both decide to
+ // write/log. Using the Entry mutex is sufficient and cheap here.
+ std::lock_guard<std::mutex> Lock(Entry.Mutex);
+ // If Timestamp is non-zero, we already recorded a timestamp for this
+ // module in this process; don't log again.
+ time_t Current = Entry.Timestamp.load();
+ if (Current != 0)
+ return;
+ time_t Now = llvm::sys::toTimeT(std::chrono::system_clock::now());
+ Entry.Timestamp.store(Now);
+ Logger.log() << "timestamp_write: " << Filename;
}
```
https://github.com/llvm/llvm-project/pull/211885
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits