[all-commits] [llvm/llvm-project] 8832a5: [clang] Enable making the module build stack threa...

Jan Svoboda via All-commits all-commits at lists.llvm.org
Thu Apr 24 10:19:08 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8832a5950f3b62331842ecb2f3a68f33732822eb
      https://github.com/llvm/llvm-project/commit/8832a5950f3b62331842ecb2f3a68f33732822eb
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2025-04-24 (Thu, 24 Apr 2025)

  Changed paths:
    M clang/lib/Frontend/CompilerInstance.cpp

  Log Message:
  -----------
  [clang] Enable making the module build stack thread-safe (#137059)

This PR makes another piece of the
`CompilerInstance::cloneForModuleCompile()` result thread-safe: the
module build stack. This data structure is used to detect cyclic
dependencies between modules. The problem is that it uses
`FullSourceLoc` which refers to the `SourceManager` of the parent
`CompilerInstance`: if two threads happen to execute `CompilerInstance`s
cloned from the same parent concurrently, and both discover a dependency
cycle, they may concurrently access the parent `SourceManager` when
emitting the diagnostic, creating a data race.

In this PR, we prevent this by keeping the stack empty and moving the
responsibility of cycle detection to the client. The client can recreate
the same module build stack externally and ensure thread-safety by
enforcing mutual exclusion.



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