From ab7abcc2d80082470bd03630b43c19f39a6d5a2b Mon Sep 17 00:00:00 2001 From: Christopher Bate Date: Mon, 19 Aug 2024 18:49:07 +0000 Subject: [PATCH 1/2] [mlir] NFC: fix dependence of (Tensor|Linalg|MemRef|Complex) dialects on LLVM Dialect and LLVM Core in CMake build This change removes dependencies declared as either 'LINK_LIBS' or 'LINK_COMPONENTS' across several MLIR libraries. The removed dependencies appear to be incorrect and may have been required in older versions of the project. These dependencies cause many high level dialects to have transitive dependence on the LLVM dialect and the LLVM 'Core' library ('llvm/lib/IR'). Note that if using the 'Ninja' CMake generator, one can inspect the dependencies (including all transitive libraries) of any given MLIR target but using the command `ninja -C -t browse` and navigating to the library of interest in a web browser. --- mlir/lib/Conversion/AffineToStandard/CMakeLists.txt | 3 --- mlir/lib/Conversion/ControlFlowToSCF/CMakeLists.txt | 6 +----- mlir/lib/Conversion/ControlFlowToSCF/ControlFlowToSCF.cpp | 1 - mlir/lib/Conversion/SCFToControlFlow/CMakeLists.txt | 5 +---- mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp | 5 ++--- mlir/lib/Conversion/VectorToSCF/CMakeLists.txt | 4 ---- mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt | 1 - mlir/lib/Dialect/Complex/IR/CMakeLists.txt | 1 - mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt | 2 -- mlir/lib/Dialect/MemRef/IR/CMakeLists.txt | 3 --- mlir/lib/Dialect/Tensor/IR/CMakeLists.txt | 3 --- 11 files changed, 4 insertions(+), 30 deletions(-) diff --git a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt index f41e3ca27ee4d..cd8193aee8da3 100644 --- a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt @@ -7,9 +7,6 @@ add_mlir_conversion_library(MLIRAffineToStandard DEPENDS MLIRConversionPassIncGen - LINK_COMPONENTS - Core - LINK_LIBS PUBLIC MLIRAffineDialect MLIRAffineTransforms diff --git a/mlir/lib/Conversion/ControlFlowToSCF/CMakeLists.txt b/mlir/lib/Conversion/ControlFlowToSCF/CMakeLists.txt index 679eca3dfa988..e7024dfbd5ee3 100644 --- a/mlir/lib/Conversion/ControlFlowToSCF/CMakeLists.txt +++ b/mlir/lib/Conversion/ControlFlowToSCF/CMakeLists.txt @@ -5,11 +5,7 @@ add_mlir_conversion_library(MLIRControlFlowToSCF ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/ControlFlowToSCF DEPENDS - MLIRConversionPassIncGen - intrinsics_gen - - LINK_COMPONENTS - Core + MLIRConversionPassIncGen LINK_LIBS PUBLIC MLIRAnalysis diff --git a/mlir/lib/Conversion/ControlFlowToSCF/ControlFlowToSCF.cpp b/mlir/lib/Conversion/ControlFlowToSCF/ControlFlowToSCF.cpp index d3ee89743da9d..1c592d665f3e4 100644 --- a/mlir/lib/Conversion/ControlFlowToSCF/ControlFlowToSCF.cpp +++ b/mlir/lib/Conversion/ControlFlowToSCF/ControlFlowToSCF.cpp @@ -16,7 +16,6 @@ #include "mlir/Dialect/ControlFlow/IR/ControlFlow.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" #include "mlir/Dialect/Func/IR/FuncOps.h" -#include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/SCF/IR/SCF.h" #include "mlir/Dialect/UB/IR/UBOps.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/lib/Conversion/SCFToControlFlow/CMakeLists.txt b/mlir/lib/Conversion/SCFToControlFlow/CMakeLists.txt index 63c5199af9290..ff64b8fcca083 100644 --- a/mlir/lib/Conversion/SCFToControlFlow/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToControlFlow/CMakeLists.txt @@ -5,10 +5,7 @@ add_mlir_conversion_library(MLIRSCFToControlFlow ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/SCFToControlFlow DEPENDS - MLIRConversionPassIncGen - - LINK_COMPONENTS - Core + MLIRConversionPassIncGen LINK_LIBS PUBLIC MLIRArithDialect diff --git a/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp b/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp index 2372ab5b82a77..cef96c206dda5 100644 --- a/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp +++ b/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp @@ -15,7 +15,6 @@ #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" -#include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/SCF/IR/SCF.h" #include "mlir/Dialect/SCF/Transforms/Transforms.h" #include "mlir/IR/Builders.h" @@ -379,8 +378,8 @@ LogicalResult ForLowering::matchAndRewrite(ForOp forOp, // llvm.loop_annotation attribute. SmallVector llvmAttrs; llvm::copy_if(forOp->getAttrs(), std::back_inserter(llvmAttrs), - [](auto attr) { - return isa(attr.getValue().getDialect()); + [](NamedAttribute attr) { + return attr.getValue().getDialect().getNamespace() == "llvm"; }); condBranchOp->setDiscardableAttrs(llvmAttrs); // The result of the loop operation is the values of the condition block diff --git a/mlir/lib/Conversion/VectorToSCF/CMakeLists.txt b/mlir/lib/Conversion/VectorToSCF/CMakeLists.txt index 83bbc4a4bc395..0915270e453df 100644 --- a/mlir/lib/Conversion/VectorToSCF/CMakeLists.txt +++ b/mlir/lib/Conversion/VectorToSCF/CMakeLists.txt @@ -4,12 +4,8 @@ add_mlir_conversion_library(MLIRVectorToSCF ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/VectorToSCF - LINK_COMPONENTS - Core - LINK_LIBS PUBLIC MLIRArithDialect - MLIRLLVMDialect MLIRMemRefDialect MLIRTransforms MLIRVectorDialect diff --git a/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt index 60d14a373348d..772f15335d907 100644 --- a/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt @@ -39,6 +39,5 @@ add_mlir_dialect_library(MLIRAffineTransforms MLIRValueBoundsOpInterface MLIRVectorDialect MLIRVectorUtils - MLIRVectorToLLVM ) diff --git a/mlir/lib/Dialect/Complex/IR/CMakeLists.txt b/mlir/lib/Dialect/Complex/IR/CMakeLists.txt index 3ee0d26f3225f..a90f34ec1684d 100644 --- a/mlir/lib/Dialect/Complex/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Complex/IR/CMakeLists.txt @@ -10,7 +10,6 @@ add_mlir_dialect_library(MLIRComplexDialect MLIRComplexAttributesIncGen LINK_LIBS PUBLIC - MLIRArithAttrToLLVMConversion MLIRArithDialect MLIRDialect MLIRInferTypeOpInterface diff --git a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt index a7dcc29b5b9be..47af392def94a 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt @@ -60,7 +60,6 @@ add_mlir_dialect_library(MLIRLinalgTransforms MLIRDestinationStyleOpInterface MLIRDialectUtils MLIRFuncDialect - MLIRFuncToLLVM MLIRFuncTransforms MLIRIndexDialect MLIRInferTypeOpInterface @@ -87,6 +86,5 @@ add_mlir_dialect_library(MLIRLinalgTransforms MLIRVectorDialect MLIRVectorTransforms MLIRVectorUtils - MLIRX86VectorTransforms MLIRVectorToSCF ) diff --git a/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt b/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt index fd2fed28badd6..845914ebd107a 100644 --- a/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt @@ -10,9 +10,6 @@ add_mlir_dialect_library(MLIRMemRefDialect DEPENDS MLIRMemRefOpsIncGen - LINK_COMPONENTS - Core - LINK_LIBS PUBLIC MLIRArithDialect MLIRArithUtils diff --git a/mlir/lib/Dialect/Tensor/IR/CMakeLists.txt b/mlir/lib/Dialect/Tensor/IR/CMakeLists.txt index 549b9f10388bd..cfdd3847761a4 100644 --- a/mlir/lib/Dialect/Tensor/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Tensor/IR/CMakeLists.txt @@ -17,9 +17,6 @@ add_mlir_dialect_library(MLIRTensorDialect DEPENDS MLIRTensorOpsIncGen - LINK_COMPONENTS - Core - LINK_LIBS PUBLIC MLIRAffineDialect MLIRArithDialect From b6ee11398377eacd10b5411eeec35e364edc4aa2 Mon Sep 17 00:00:00 2001 From: Christopher Bate Date: Mon, 19 Aug 2024 19:45:01 +0000 Subject: [PATCH 2/2] Add missing dependence for MLIRMemrefTransformOps on MLIRVectorTransforms --- mlir/lib/Dialect/MemRef/TransformOps/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/mlir/lib/Dialect/MemRef/TransformOps/CMakeLists.txt b/mlir/lib/Dialect/MemRef/TransformOps/CMakeLists.txt index e379663f3b0a0..4c9e3d3c813f7 100644 --- a/mlir/lib/Dialect/MemRef/TransformOps/CMakeLists.txt +++ b/mlir/lib/Dialect/MemRef/TransformOps/CMakeLists.txt @@ -19,4 +19,5 @@ add_mlir_dialect_library(MLIRMemRefTransformOps MLIRNVGPUDialect MLIRTransformDialect MLIRVectorDialect + MLIRVectorTransforms )