https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/221616
CIR's sources reference Arith, DLTI, Func, LLVM, OpenACC, OpenMP and Ptr, and cir-opt registers only the CIR dialects plus MemRef and LLVM. Link those instead, which keeps Linalg, Vector, SPIRV, SparseTensor, Tosa and GPU out of the clang build graph. CLANG_ENABLE_CIR=ON adds 2135 build edges to the clang target; this removes 694 of them. LLM-aided >From d9c9eb4590f63f4c8bd64cfbfdfcd109dcac856a Mon Sep 17 00:00:00 2001 From: Fangrui Song <[email protected]> Date: Sun, 6 Sep 2026 16:46:22 -0700 Subject: [PATCH] [CMake] Link only the MLIR dialects ClangIR uses CIR's sources reference Arith, DLTI, Func, LLVM, OpenACC, OpenMP and Ptr, and cir-opt registers only the CIR dialects plus MemRef and LLVM. Link those instead, which keeps Linalg, Vector, SPIRV, SparseTensor, Tosa and GPU out of the clang build graph. CLANG_ENABLE_CIR=ON adds 2135 build edges to the clang target; this removes 694 of them. LLM-aided --- clang/lib/CIR/CodeGen/CMakeLists.txt | 12 ++++++++---- clang/lib/CIR/FrontendAction/CMakeLists.txt | 2 -- clang/lib/CIR/Interfaces/CMakeLists.txt | 1 - clang/lib/CIR/Lowering/CMakeLists.txt | 3 --- clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt | 8 +++++--- clang/tools/cir-opt/CMakeLists.txt | 7 ++----- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/clang/lib/CIR/CodeGen/CMakeLists.txt b/clang/lib/CIR/CodeGen/CMakeLists.txt index 0fd5cdfb02540..c4bd520fc61b7 100644 --- a/clang/lib/CIR/CodeGen/CMakeLists.txt +++ b/clang/lib/CIR/CodeGen/CMakeLists.txt @@ -1,11 +1,10 @@ set( LLVM_LINK_COMPONENTS Core + FrontendOpenMP Support ) -get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) - add_clang_library(clangCIR CIRDataLayoutSpec.cpp CIRGenerator.cpp @@ -64,18 +63,23 @@ add_clang_library(clangCIR DEPENDS MLIRCIR MLIRCIROpInterfacesIncGen - ${dialect_libs} LINK_LIBS clangAST clangBasic clangCodeGenUtils clangLex - ${dialect_libs} CIRRegisterAllDialects CIROpenACCSupport CIROpenMPSupport + MLIRArithDialect MLIRCIR MLIRCIRInterfaces + MLIRDLTIDialect + MLIRLLVMDialect + MLIROpenACCDialect + MLIROpenMPDialect + MLIROpenMPUtils + MLIRPtrMemorySpaceInterfaces MLIRTargetLLVMIRImport ) diff --git a/clang/lib/CIR/FrontendAction/CMakeLists.txt b/clang/lib/CIR/FrontendAction/CMakeLists.txt index 9577a907c9334..d221771fd4086 100644 --- a/clang/lib/CIR/FrontendAction/CMakeLists.txt +++ b/clang/lib/CIR/FrontendAction/CMakeLists.txt @@ -5,8 +5,6 @@ set(LLVM_LINK_COMPONENTS Support ) -get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) - add_clang_library(clangCIRFrontendAction CIRGenAction.cpp CIRDiagnosticHandler.cpp diff --git a/clang/lib/CIR/Interfaces/CMakeLists.txt b/clang/lib/CIR/Interfaces/CMakeLists.txt index 33eb169708a4f..8eec8b05aa951 100644 --- a/clang/lib/CIR/Interfaces/CMakeLists.txt +++ b/clang/lib/CIR/Interfaces/CMakeLists.txt @@ -15,7 +15,6 @@ add_clang_library(MLIRCIRInterfaces MLIRCIROpInterfacesIncGen LINK_LIBS - ${dialect_libs} MLIRIR MLIRSupport ) diff --git a/clang/lib/CIR/Lowering/CMakeLists.txt b/clang/lib/CIR/Lowering/CMakeLists.txt index 28ec3c551018c..2713af9ba3d6c 100644 --- a/clang/lib/CIR/Lowering/CMakeLists.txt +++ b/clang/lib/CIR/Lowering/CMakeLists.txt @@ -3,15 +3,12 @@ set(LLVM_LINK_COMPONENTS Support ) -get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) - add_clang_library(clangCIRLoweringCommon CIRPasses.cpp LoweringHelpers.cpp LINK_LIBS clangCIR - ${dialect_libs} MLIRCIR MLIRCIRTransforms MLIRTransforms diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt b/clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt index 26d9f65f865be..d3d0805afb4d8 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt +++ b/clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt @@ -3,8 +3,6 @@ set(LLVM_LINK_COMPONENTS Support ) -get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) - add_clang_library(clangCIRLoweringDirectToLLVM LowerToLLVM.cpp LowerToLLVMIR.cpp @@ -18,12 +16,16 @@ add_clang_library(clangCIRLoweringDirectToLLVM LINK_LIBS clangCIRLoweringCommon - ${dialect_libs} MLIRCIR MLIRCIRTargetLowering MLIRCIRTransforms MLIRBuiltinToLLVMIRTranslation + MLIRDLTIDialect + MLIRFuncDialect + MLIRLLVMCommonConversion + MLIRLLVMDialect MLIRLLVMToLLVMIRTranslation + MLIROpenMPDialect MLIROpenMPToLLVM MLIROpenMPToLLVMIRTranslation MLIROpenMPTransforms diff --git a/clang/tools/cir-opt/CMakeLists.txt b/clang/tools/cir-opt/CMakeLists.txt index 72cfff1800d41..b4ae75cfbb118 100644 --- a/clang/tools/cir-opt/CMakeLists.txt +++ b/clang/tools/cir-opt/CMakeLists.txt @@ -1,6 +1,3 @@ -get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) -get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS) - include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include) include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include) @@ -39,16 +36,16 @@ clang_target_link_libraries(cir-opt target_link_libraries(cir-opt PRIVATE - ${dialect_libs} - ${conversion_libs} MLIRAnalysis MLIRDialect MLIRIR + MLIRLLVMDialect MLIRMemRefDialect MLIROpenMPTransforms MLIROptLib MLIRParser MLIRPass + MLIRReconcileUnrealizedCasts MLIRSideEffectInterfaces MLIRTransforms MLIRTransformUtils _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
