[all-commits] [llvm/llvm-project] 9947b7: [MLIR][CMake] Extend MLIRIR PCH reuse to transitiv...
Maksim Levental via All-commits
all-commits at lists.llvm.org
Sat Aug 1 01:21:16 PDT 2026
Branch: refs/heads/users/makslevental/mlir-ir-pch
Home: https://github.com/llvm/llvm-project
Commit: 9947b7f554dd5b6f53c4c2020111082e35a38ea8
https://github.com/llvm/llvm-project/commit/9947b7f554dd5b6f53c4c2020111082e35a38ea8
Author: makslevental <maksim.levental at gmail.com>
Date: 2026-08-01 (Sat, 01 Aug 2026)
Changed paths:
M mlir/cmake/modules/AddMLIR.cmake
M mlir/lib/CMakeLists.txt
M mlir/lib/Tools/PDLL/AST/CMakeLists.txt
M mlir/lib/Tools/PDLL/ODS/CMakeLists.txt
M mlir/unittests/CMakeLists.txt
Log Message:
-----------
[MLIR][CMake] Extend MLIRIR PCH reuse to transitive dependants
llvm_update_pch() only offers a PCH to targets that name the defining
library as a *direct* dependency, because across LLVM subprojects a
transitively reused PCH drags in unrelated headers and causes name
collisions. Within MLIR that concern is much weaker: mlir/IR/pch.h holds
MLIR core headers that essentially every MLIR library includes anyway.
Add mlir_reuse_ir_pch(), which offers MLIRIR's PCH to any target that
actually reaches MLIRIR through its link graph. The reachability check
matters: a PCH containing MLIR IR headers emits out-of-line symbols that
only libMLIRIR provides, so handing it to a Support-only target such as
tblgen-lsp-server breaks the link.
The helper is called from add_mlir_library() and add_mlir_tool(), and
again from mlir_target_link_libraries(), where most tests, unittests and
libMLIR.so-avoiding libraries actually attach their MLIR dependencies. It
is idempotent and skips targets that define their own PCH, that opt out
with DISABLE_PCH_REUSE, that override RTTI/EH, or that contain C/ObjC
sources. MLIRSupport is excluded because MLIRIR links it, and PCH reuse
creates a real target dependency that would form a cycle.
add_mlir_library() now parses DISABLE_PCH_REUSE itself, so the opt-out is
visible here; previously it was consumed by llvm_add_library and left no
queryable property, which silently defeated the C API opt-out from
llvm#182862.
mlir/lib/CMakeLists.txt processes Interfaces, Pass and Rewrite right after
IR, so that the libraries carrying the dependency edge to MLIRIR exist
before their dependants are configured.
PDLL opts out: mlir::pdll::ast::Type/TupleType/InFlightDiagnostic and
mlir::pdll::ods::Dialect/Operation collide with the mlir:: names in the
PCH. Those libraries only link MLIRSupport, so the PCH is of no use there.
Together this takes PCH reuse from 715 to 1122 of 1536 MLIR objects.
check-mlir passes with 0 unexpected failures.
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