[all-commits] [llvm/llvm-project] a730dd: [clang][DependencyScanning] Logging Dependency Sca...

Qiongsi Wu via All-commits all-commits at lists.llvm.org
Thu Jul 16 10:41:44 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a730dda7d520cff562e77efbe02b5bba470a2b36
      https://github.com/llvm/llvm-project/commit/a730dda7d520cff562e77efbe02b5bba470a2b36
  Author: Qiongsi Wu <qiongsiwu at gmail.com>
  Date:   2026-07-16 (Thu, 16 Jul 2026)

  Changed paths:
    M clang/include/clang/Basic/AtomicLineLogger.h
    M clang/include/clang/DependencyScanning/DependencyScanningService.h
    M clang/include/clang/DependencyScanning/DependencyScanningWorker.h
    M clang/include/clang/DependencyScanning/InProcessModuleCache.h
    M clang/include/clang/Serialization/InMemoryModuleCache.h
    M clang/include/clang/Serialization/ModuleCache.h
    M clang/lib/DependencyScanning/DependencyScannerImpl.cpp
    M clang/lib/DependencyScanning/DependencyScanningWorker.cpp
    M clang/lib/DependencyScanning/InProcessModuleCache.cpp
    M clang/lib/Frontend/CompilerInstance.cpp
    M clang/lib/Serialization/InMemoryModuleCache.cpp
    M clang/lib/Serialization/ModuleCache.cpp
    M clang/lib/Tooling/DependencyScanningTool.cpp
    A clang/test/ClangScanDeps/logging-drop-pcm.c
    A clang/test/ClangScanDeps/logging-simple-by-name.c
    A clang/test/ClangScanDeps/logging-simple.c
    A clang/test/ClangScanDeps/logging-two-threads.c
    M clang/tools/clang-scan-deps/ClangScanDeps.cpp
    M clang/tools/clang-scan-deps/Opts.td
    M clang/unittests/Basic/AtomicLineLoggerTest.cpp
    M clang/unittests/DependencyScanning/InProcessModuleCacheTest.cpp
    M clang/unittests/Serialization/InMemoryModuleCacheTest.cpp

  Log Message:
  -----------
  [clang][DependencyScanning] Logging Dependency Scanning Events (#195896)

This PR sets up an `AtomicLineLogger` (added by
https://github.com/llvm/llvm-project/pull/205395) to log the sequence of
dependency scanning events. The logging is triggered by a new `LogPath`
option in `DependencyScanningServiceOptions`. This PR adds an option
`-log-path=` to `clang-scan-deps` to trigger the log.

We are logging 16 events during dependency scanning. 

| Event | Logged In | When |
|-------|-----------|------|
| `starting scanning command: <args>` | `DependencyScanningWorker.cpp` |
Start of each TU scan |
| `finished scanning command: <args>` | `DependencyScanningWorker.cpp` |
End of each TU scan |
| `init_compiler_instance_with_context: <args>` |
`DependencyScanningTool.cpp` | CompilerInstanceWithContext created for
by-name scanning |
| `start scan_by_name: <module name>` | `DependencyScanningTool.cpp` |
Start of a by-name module query |
| `finish scan_by_name: <module name>` | `DependencyScanningTool.cpp` |
End of a by-name module query |
| `module_compile_thread: parent=<TID> pcm_compile: <pcm path>` |
`CompilerInstance::compileModule` | A new thread is created to compile a
pcm |
| `timestamp_read: <pcm path>` |
`InProcessModuleCache::getModuleTimestamp` | Validation timestamp read |
| `timestamp_write: <pcm path>` |
`InProcessModuleCache::updateModuleTimestamp` | Validation timestamp
update |
| `pcm_write: <pcm path>` | `InProcessModuleCache::write` | PCM write to
disk attempted |
| `pcm_read_disk: <pcm path>` | `InProcessModuleCache::read` | PCM read
from disk attempted |
| `pcm_read_cached: <pcm path>` | `InMemoryModuleCache::lookupPCM` | PCM
looked up in in-memory cache |
| `pcm_add: <pcm path>` | `InMemoryModuleCache::addPCM` | PCM added to
cache (not validated) |
| `pcm_add_built: <pcm path>` | `InMemoryModuleCache::addBuiltPCM` | PCM
added to cache (final) |
| `pcm_finalized: <pcm path>` | `InMemoryModuleCache::finalizePCM` | PCM
marked as validated/final |
| `pcm_dropped: <pcm path>` | `InMemoryModuleCache::tryToDropPCM` | PCM
dropped (validation failed) |
| `pcm_not_dropped: <pcm path>` | `InMemoryModuleCache::tryToDropPCM` |
PCM not dropped (validation failed, but already final) |

In addition to checking the logger's functionality,
`clang/test/ClangScanDeps/logging-simple.c` checks against the change
committed by https://github.com/llvm/llvm-project/pull/177062. Without
https://github.com/llvm/llvm-project/pull/177062,
`clang/test/ClangScanDeps/logging-simple.c` fails.

This implementation adds a single instance of `AtomicLineLogger` to the
`DependencyScanningService`. Most of the plumbing goes into the
`ModuleCache` and its derived classes.

Assisted-by: claude-opus-4.6

rdar://39907408



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list