[llvm-branch-commits] [mlir] [mlir][LLVM] Reuse a PCH for MLIRLLVMDialect (NFC) (PR #222578)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Sep 10 03:04:56 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Mehdi Amini (joker-eph)

<details>
<summary>Changes</summary>

Build a private precompiled header from the LLVM dialect and LLVM IR headers and use it for MLIRLLVMDialect. Build dialect libraries before conversions so the PCH is available early and repeated parsing is avoided.

Relative to the MLIRIR PCH parent, clean Release builds of LLVM and MLIR with `ninja -j16` improved as follows:

```
  wall:   420.41s -> 398.79s (-5.14%)
  user:  6125.97s -> 5789.14s (-5.50%)
  system: 481.88s -> 455.05s (-5.57%)
```

Assisted-by: Codex

---
Full diff: https://github.com/llvm/llvm-project/pull/222578.diff


3 Files Affected:

- (added) mlir/include/mlir/Dialect/LLVMIR/pch.h (+14) 
- (modified) mlir/lib/CMakeLists.txt (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/CMakeLists.txt (+3) 


``````````diff
diff --git a/mlir/include/mlir/Dialect/LLVMIR/pch.h b/mlir/include/mlir/Dialect/LLVMIR/pch.h
new file mode 100644
index 0000000000000..644a670894515
--- /dev/null
+++ b/mlir/include/mlir/Dialect/LLVMIR/pch.h
@@ -0,0 +1,14 @@
+//===- pch.h - Precompiled header for MLIR LLVM dialect --------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// Precompiled header for MLIRLLVMDialect.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
+#include "llvm/IR/pch.h"
diff --git a/mlir/lib/CMakeLists.txt b/mlir/lib/CMakeLists.txt
index 7adf344099ed2..97adaa3e26631 100644
--- a/mlir/lib/CMakeLists.txt
+++ b/mlir/lib/CMakeLists.txt
@@ -7,9 +7,9 @@ add_subdirectory(ABI)
 add_subdirectory(Analysis)
 add_subdirectory(AsmParser)
 add_subdirectory(Bytecode)
+add_subdirectory(Dialect)
 add_subdirectory(Conversion)
 add_subdirectory(Debug)
-add_subdirectory(Dialect)
 add_subdirectory(Interfaces)
 add_subdirectory(Parser)
 add_subdirectory(Pass)
diff --git a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
index aa65ae820c817..cae75e5c2dfe4 100644
--- a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
+++ b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
@@ -28,6 +28,9 @@ add_mlir_dialect_library(MLIRLLVMDialect
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
 
+  PRECOMPILE_HEADERS
+  [["mlir/Dialect/LLVMIR/pch.h"]]
+
   DEPENDS
   MLIRLLVMDialectBytecodeIncGen
   MLIRLLVMInterfacesIncGen

``````````

</details>


https://github.com/llvm/llvm-project/pull/222578


More information about the llvm-branch-commits mailing list