[Mlir-commits] [mlir] [mlir][LLVMIR] Precompile NVVM and ROCDL operation declarations (PR #233106)
Mehdi Amini
llvmlistbot at llvm.org
Sat Oct 17 08:59:44 PDT 2026
https://github.com/joker-eph created https://github.com/llvm/llvm-project/pull/233106
The eight source shards in each dialect repeatedly parse their operation headers after loading the shared LLVM PCH. Give each dialect a local PCH containing LLVMIR/pch.h followed by its operation header. Disable downstream reuse so other libraries retain their existing PCH selection.
Reduces CPU from 103.12 to 87.48 s (-15.17%) for the affected objects.
Assisted-by: Codex
>From 0414d0f9ee42f37a70a861671b74a02e65c7d9f7 Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Fri, 16 Oct 2026 15:58:55 -0700
Subject: [PATCH] [mlir][LLVMIR] Precompile NVVM and ROCDL operation
declarations
The eight source shards in each dialect repeatedly parse their operation
headers after loading the shared LLVM PCH. Give each dialect a local PCH
containing LLVMIR/pch.h followed by its operation header. Disable downstream
reuse so other libraries retain their existing PCH selection.
On a Ryzen 9 7950X with Clang 22.1.0, Release, assertions disabled, the
Native target, ccache bypassed, CPUs 8-24 and -j17, two clean mlir-opt
samples per variant in ABBA order measured:
user + system CPU: 4843.84 s -> 4798.90 s (-0.93%)
elapsed: 296.25 s -> 294.34 s (-0.65%)
retired user instructions: -0.345%
Both pairs save CPU (32.55 s and 57.33 s). Baseline CPU samples range from
4831.28 to 4856.40 s; candidate samples range from 4798.73 to 4799.07 s.
No competing compiler work was detected in accepted samples. Both source
states include the existing NVVM ModuleTranslation cleanup from #232727.
Focused serial compilation of all 21 affected sources, including 13.65 s
of new PCH creation, reduces CPU from 103.12 to 87.48 s (-15.17%).
Representative shard edits save about 1.5 s elapsed. Operation-header edits
reduce CPU by 9.44% for NVVM and 7.53% for ROCDL, but elapsed grows from
14.12 to 17.91 s and 16.98 to 17.69 s, respectively, as PCH creation gates
local consumers. NVVM also newly invalidates BasicPtxBuilderInterface.cpp
and NVVMRequiresSMTraits.cpp. The two PCHs add 347 MiB of disk storage;
creation peaks at about 1.14 GiB of process RSS.
Fresh PCH-enabled and PCH-disabled mlir-opt builds pass. Baseline, candidate
and PCH-disabled builds each pass 558 LLVMIR dialect/translation tests,
with the same two unsupported tests. Ninja reports no missing generated
dependencies. All 21 affected objects preserve code, data, relocations and
symbol tables; differences are limited to equivalent .llvm_addrsig order.
Downstream compile commands and all non-PCH compiler options are unchanged.
Assisted-by: Codex
---
mlir/lib/Dialect/LLVMIR/CMakeLists.txt | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
index 6b7827d5ab12b5..b39526e88fcefc 100644
--- a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
+++ b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt
@@ -81,6 +81,13 @@ add_mlir_dialect_library(MLIRNVVMDialect
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
+ # Cache the operation declarations shared by all source shards. Keep this
+ # specialized PCH local rather than making downstream libraries reuse it.
+ DISABLE_PCH_REUSE
+ PRECOMPILE_HEADERS
+ [["mlir/Dialect/LLVMIR/pch.h"]]
+ [["mlir/Dialect/LLVMIR/NVVMDialect.h"]]
+
DEPENDS
MLIRGPUCompilationAttrInterfacesIncGen
MLIRNVVMOpsIncGen
@@ -121,6 +128,13 @@ add_mlir_dialect_library(MLIRROCDLDialect
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR
+ # Cache the operation declarations shared by all source shards. Keep this
+ # specialized PCH local rather than making downstream libraries reuse it.
+ DISABLE_PCH_REUSE
+ PRECOMPILE_HEADERS
+ [["mlir/Dialect/LLVMIR/pch.h"]]
+ [["mlir/Dialect/LLVMIR/ROCDLDialect.h"]]
+
DEPENDS
MLIRGPUCompilationAttrInterfacesIncGen
MLIRROCDLOpsIncGen
More information about the Mlir-commits
mailing list