[Mlir-commits] [mlir] [mlir][NVVM][NFC] Predeclare `ModuleTranslation` to improve build times (PR #232727)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Oct 16 05:57:26 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-nvptx

Author: Markus Böck (zero9178)

<details>
<summary>Changes</summary>

The NVVMDialect's LLVM IR export is currently layered such that it is interwoven with the dialect implementation. For many ops, a `getIntrinsicIDAndArgs` method implements the translation to LLVM IR and requires the declaration of `mlir::LLVM::ModuleTranslation`. The header for the latter is a rather heavy header that includes all of OpenMP Dialect and more.

This PR makes NVVMDialect.h faster to parse by predeclaring `mlir::LLVM::ModuleTranslation` rather than including its definition. In a local build tested on a AMD Ryzen Threadripper PRO 5975WX this saved aorund 2.4s of compile time per-file that includes NVVMDialect.h for a total of 65.4s of CPU time saved.

I believe that ideally the LLVM IR translation should be moved to and contained in NVVMToLLVMIRTranslation but is left as a future change after these "easy" compile time changes have been applied.

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


2 Files Affected:

- (modified) mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h (+3-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp (+1) 


``````````diff
diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h
index 0cc509c062c5d..31df487dac967 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h
@@ -25,7 +25,6 @@
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/Interfaces/InferIntRangeInterface.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"
-#include "mlir/Target/LLVMIR/ModuleTranslation.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 #include "mlir/Dialect/LLVMIR/NVVMOpsEnums.h.inc"
@@ -62,6 +61,9 @@ std::pair<mlir::Type, unsigned> inferMMAType(mlir::NVVM::MMATypes type,
                                              int nCol,
                                              mlir::MLIRContext *context);
 } // namespace NVVM
+namespace LLVM {
+class ModuleTranslation;
+} // namespace LLVM
 } // namespace mlir
 
 ///// Ops /////
diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
index 1a300b1e7f41c..bb2db355d567f 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
@@ -30,6 +30,7 @@
 #include "mlir/IR/Operation.h"
 #include "mlir/IR/OperationSupport.h"
 #include "mlir/IR/Types.h"
+#include "mlir/Target/LLVMIR/ModuleTranslation.h"
 #include "mlir/Transforms/InliningUtils.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/TypeSwitch.h"

``````````

</details>


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


More information about the Mlir-commits mailing list