[llvm] [mlir] [mlir] Drop unused CodeGenTypes link dependency from mlir-tblgen (PR #228204)

Julien Schueller via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 01:47:40 PDT 2026


https://github.com/jschueller updated https://github.com/llvm/llvm-project/pull/228204

>From de8c546114797310491e7a89ee68f7ea3a3d72eb Mon Sep 17 00:00:00 2001
From: Julien Schueller <schueller at phimeca.com>
Date: Thu, 1 Oct 2026 21:11:49 +0200
Subject: [PATCH] [mlir] Drop unused CodeGenTypes link dependency from
 mlir-tblgen

mlir-tblgen only needs llvm/CodeGenTypes/MachineValueType.h, and uses
from it nothing but the nested MVT::SimpleValueType enum and its
enumerators. No symbol from libLLVMCoreGenTypes.a (MVT/LLT, defined in
LowLevelType.cpp) is referenced, so the CodeGenTypes link component is
spurious.

This goes unnoticed in in-tree builds, where the component static
library is always available. It does break standalone MLIR builds
against an installed LLVM that ships a single libLLVM.so rather than
per-component static libraries -- e.g. Arch's llvm package provides
libLLVMSupport/libLLVMTableGen/libLLVMDemangle but not
libLLVMCoreGenTypes. Note that add_tablegen() passes
DISABLE_LLVM_LINK_LLVM_DYLIB, so tblgen tools always link component
libraries and never fall back to the dylib.

The component was originally added by "Try to fix CodeGenTypes issues
in mlir" (ea2b79d48d71) to accompany the include path move to
llvm/CodeGen/ in Bazel, not for an actual link requirement. Drop it from
both CMake and the Bazel overlay.
---
 mlir/tools/mlir-tblgen/CMakeLists.txt             | 7 ++++++-
 utils/bazel/llvm-project-overlay/mlir/BUILD.bazel | 1 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/mlir/tools/mlir-tblgen/CMakeLists.txt b/mlir/tools/mlir-tblgen/CMakeLists.txt
index 936c84ef58b2b..5bc316de78e1d 100644
--- a/mlir/tools/mlir-tblgen/CMakeLists.txt
+++ b/mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -1,5 +1,4 @@
 set(LLVM_LINK_COMPONENTS
-  CodeGenTypes
   Demangle
   Support
   TableGen
@@ -34,6 +33,12 @@ add_tablegen(mlir-tblgen MLIR
   RewriterGen.cpp
   SPIRVUtilsGen.cpp
   CppGenUtilities.cpp
+
+  DEPENDS
+  # LLVMIRIntrinsicGen.cpp includes llvm/CodeGen/GenVT.inc, which is
+  # generated by vt_gen. This is a no-op when building against an installed
+  # LLVM, where the generated headers are already shipped.
+  vt_gen
   )
 
 target_link_libraries(mlir-tblgen
diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index 28388e354e91e..e3baf23b54b2b 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -10563,7 +10563,6 @@ cc_binary(
         ":MlirTableGenMain",
         ":Support",
         ":TableGen",
-        "//llvm:CodeGenTypes",
         "//llvm:Support",
         "//llvm:TableGen",
         "//llvm:TargetParser",



More information about the llvm-commits mailing list