[Mlir-commits] [mlir] 1fc096a - Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Sat Jan 1 17:49:42 PST 2022
Author: Mehdi Amini
Date: 2022-01-02T01:45:18Z
New Revision: 1fc096af1e495d121679340b527701a5c0a9ef8b
URL: https://github.com/llvm/llvm-project/commit/1fc096af1e495d121679340b527701a5c0a9ef8b
DIFF: https://github.com/llvm/llvm-project/commit/1fc096af1e495d121679340b527701a5c0a9ef8b.diff
LOG: Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC)
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D116250
Added:
Modified:
mlir/include/mlir/Analysis/NestedMatcher.h
mlir/include/mlir/Dialect/Async/Transforms.h
mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
mlir/include/mlir/Dialect/Linalg/Passes.h
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/IR/AffineMap.h
mlir/include/mlir/IR/Dialect.h
mlir/include/mlir/Reducer/ReductionNode.h
mlir/include/mlir/TableGen/GenInfo.h
mlir/include/mlir/TableGen/Pattern.h
mlir/include/mlir/Translation.h
mlir/lib/Analysis/LoopAnalysis.cpp
mlir/lib/Analysis/NestedMatcher.cpp
mlir/lib/Bindings/Python/DialectSparseTensor.cpp
mlir/lib/Bindings/Python/Dialects.h
mlir/lib/Bindings/Python/ExecutionEngineModule.cpp
mlir/lib/Bindings/Python/IRAffine.cpp
mlir/lib/Bindings/Python/IRAttributes.cpp
mlir/lib/Bindings/Python/IRCore.cpp
mlir/lib/Bindings/Python/IRInterfaces.cpp
mlir/lib/Bindings/Python/IRModule.h
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp
mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp
mlir/lib/Dialect/Linalg/ComprehensiveBufferize/SCFInterfaceImpl.cpp
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
mlir/lib/Dialect/Linalg/Transforms/Distribution.cpp
mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
mlir/lib/Dialect/Vector/VectorMultiDimReductionTransforms.cpp
mlir/lib/IR/AffineExpr.cpp
mlir/lib/IR/AffineMap.cpp
mlir/lib/IR/Diagnostics.cpp
mlir/lib/IR/Dialect.cpp
mlir/lib/IR/Operation.cpp
mlir/lib/Pass/IRPrinting.cpp
mlir/lib/Pass/PassRegistry.cpp
mlir/lib/Reducer/ReductionNode.cpp
mlir/lib/TableGen/Pattern.cpp
mlir/lib/TableGen/Predicate.cpp
mlir/lib/Target/Cpp/TranslateToCpp.cpp
mlir/lib/Tools/mlir-lsp-server/lsp/Transport.cpp
mlir/lib/Transforms/Inliner.cpp
mlir/lib/Transforms/ViewOpGraph.cpp
mlir/lib/Translation/Translation.cpp
mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp
mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp
mlir/tools/mlir-tblgen/DialectGen.cpp
mlir/tools/mlir-tblgen/OpDocGen.cpp
mlir/tools/mlir-tblgen/OpFormatGen.cpp
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
mlir/tools/mlir-tblgen/mlir-tblgen.cpp
mlir/unittests/Analysis/AffineStructuresParserTest.cpp
mlir/unittests/Analysis/Presburger/SimplexTest.cpp
mlir/unittests/Analysis/PresburgerSetTest.cpp
mlir/unittests/Conversion/PDLToPDLInterp/RootOrderingTest.cpp
mlir/unittests/Dialect/SparseTensor/MergerTest.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/NestedMatcher.h b/mlir/include/mlir/Analysis/NestedMatcher.h
index fb725e3ec864..844fc3a53ad1 100644
--- a/mlir/include/mlir/Analysis/NestedMatcher.h
+++ b/mlir/include/mlir/Analysis/NestedMatcher.h
@@ -180,15 +180,15 @@ class NestedPatternContext {
namespace matcher {
// Syntactic sugar NestedPattern builder functions.
NestedPattern Op(FilterFunctionType filter = defaultFilterFunction);
-NestedPattern If(NestedPattern child);
-NestedPattern If(FilterFunctionType filter, NestedPattern child);
+NestedPattern If(const NestedPattern &child);
+NestedPattern If(const FilterFunctionType &filter, const NestedPattern &child);
NestedPattern If(ArrayRef<NestedPattern> nested = {});
-NestedPattern If(FilterFunctionType filter,
+NestedPattern If(const FilterFunctionType &filter,
ArrayRef<NestedPattern> nested = {});
-NestedPattern For(NestedPattern child);
-NestedPattern For(FilterFunctionType filter, NestedPattern child);
+NestedPattern For(const NestedPattern &child);
+NestedPattern For(const FilterFunctionType &filter, const NestedPattern &child);
NestedPattern For(ArrayRef<NestedPattern> nested = {});
-NestedPattern For(FilterFunctionType filter,
+NestedPattern For(const FilterFunctionType &filter,
ArrayRef<NestedPattern> nested = {});
bool isParallelLoop(Operation &op);
diff --git a/mlir/include/mlir/Dialect/Async/Transforms.h b/mlir/include/mlir/Dialect/Async/Transforms.h
index 97a070b0757e..09a57ca89708 100644
--- a/mlir/include/mlir/Dialect/Async/Transforms.h
+++ b/mlir/include/mlir/Dialect/Async/Transforms.h
@@ -32,7 +32,7 @@ using AsyncMinTaskSizeComputationFunction =
/// operations.
void populateAsyncParallelForPatterns(
RewritePatternSet &patterns, bool asyncDispatch, int32_t numWorkerThreads,
- AsyncMinTaskSizeComputationFunction computeMinTaskSize);
+ const AsyncMinTaskSizeComputationFunction &computeMinTaskSize);
} // namespace async
} // namespace mlir
diff --git a/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
index 891d59b61616..6d0a32cfd344 100644
--- a/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
+++ b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
@@ -352,7 +352,7 @@ class BufferizationState {
/// { 2, 7, 8, 5 }
llvm::SetVector<Value>
findValueInReverseUseDefChain(Value value,
- std::function<bool(Value)> condition);
+ llvm::function_ref<bool(Value)> condition);
/// Find the Value of the last preceding write of a given Value.
///
diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h
index 8ebaaa8f8e4d..5b0abdec15c6 100644
--- a/mlir/include/mlir/Dialect/Linalg/Passes.h
+++ b/mlir/include/mlir/Dialect/Linalg/Passes.h
@@ -82,70 +82,70 @@ std::unique_ptr<Pass> createLinalgDetensorizePass();
//===----------------------------------------------------------------------===//
/// Create a LinalgStrategyTileAndFusePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyTileAndFusePass(
- StringRef opName = "", linalg::LinalgTilingAndFusionOptions opt = {},
- linalg::LinalgTransformationFilter filter =
+ StringRef opName = "", const linalg::LinalgTilingAndFusionOptions &opt = {},
+ const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());
/// Create a LinalgStrategyTilePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyTilePass(
StringRef opName = "",
- linalg::LinalgTilingOptions opt = linalg::LinalgTilingOptions(),
- linalg::LinalgTransformationFilter filter =
+ const linalg::LinalgTilingOptions &opt = linalg::LinalgTilingOptions(),
+ const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());
/// Create a LinalgStrategyPadPass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyPadPass(
StringRef opName = "",
- linalg::LinalgPaddingOptions opt = linalg::LinalgPaddingOptions(),
- linalg::LinalgTransformationFilter filter =
+ const linalg::LinalgPaddingOptions &opt = linalg::LinalgPaddingOptions(),
+ const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());
/// Create a LinalgStrategyPromotePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyPromotePass(
StringRef opName = "",
- linalg::LinalgPromotionOptions opt = linalg::LinalgPromotionOptions(),
- linalg::LinalgTransformationFilter filter =
+ const linalg::LinalgPromotionOptions &opt =
+ linalg::LinalgPromotionOptions(),
+ const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());
/// Create a LinalgStrategyGeneralizePass.
-std::unique_ptr<OperationPass<FuncOp>>
-createLinalgStrategyGeneralizePass(StringRef opName = "",
- linalg::LinalgTransformationFilter filter =
- linalg::LinalgTransformationFilter());
+std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyGeneralizePass(
+ StringRef opName = "", const linalg::LinalgTransformationFilter &filter =
+ linalg::LinalgTransformationFilter());
/// Create a LinalgStrategyDecomposePass.
// TODO: if/when we need finer control add an `opName` parameter.
-std::unique_ptr<OperationPass<FuncOp>>
-createLinalgStrategyDecomposePass(linalg::LinalgTransformationFilter filter =
- linalg::LinalgTransformationFilter());
+std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyDecomposePass(
+ const linalg::LinalgTransformationFilter &filter =
+ linalg::LinalgTransformationFilter());
/// Create a LinalgStrategyInterchangePass.
-std::unique_ptr<OperationPass<FuncOp>>
-createLinalgStrategyInterchangePass(ArrayRef<int64_t> iteratorInterchange = {},
- linalg::LinalgTransformationFilter filter =
- linalg::LinalgTransformationFilter());
+std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyInterchangePass(
+ ArrayRef<int64_t> iteratorInterchange = {},
+ const linalg::LinalgTransformationFilter &filter =
+ linalg::LinalgTransformationFilter());
/// Create a LinalgStrategyVectorizePass.
-std::unique_ptr<OperationPass<FuncOp>>
-createLinalgStrategyVectorizePass(StringRef opName = "",
- linalg::LinalgVectorizationOptions opt =
- linalg::LinalgVectorizationOptions(),
- linalg::LinalgTransformationFilter filter =
- linalg::LinalgTransformationFilter(),
- bool padVectorize = false);
+std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyVectorizePass(
+ StringRef opName = "",
+ linalg::LinalgVectorizationOptions opt =
+ linalg::LinalgVectorizationOptions(),
+ const linalg::LinalgTransformationFilter &filter =
+ linalg::LinalgTransformationFilter(),
+ bool padVectorize = false);
/// Create a LinalgStrategyEnablePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyEnablePass(
linalg::LinalgEnablingOptions opt = linalg::LinalgEnablingOptions(),
- linalg::LinalgTransformationFilter filter =
+ const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());
/// Create a LinalgStrategyLowerVectorsPass.
-std::unique_ptr<OperationPass<FuncOp>>
-createLinalgStrategyLowerVectorsPass(linalg::LinalgVectorLoweringOptions opt =
- linalg::LinalgVectorLoweringOptions(),
- linalg::LinalgTransformationFilter filter =
- linalg::LinalgTransformationFilter());
+std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyLowerVectorsPass(
+ linalg::LinalgVectorLoweringOptions opt =
+ linalg::LinalgVectorLoweringOptions(),
+ const linalg::LinalgTransformationFilter &filter =
+ linalg::LinalgTransformationFilter());
/// Create a LinalgStrategyRemoveMarkersPass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyRemoveMarkersPass();
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index 34eef99dc729..bb396ce5a554 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -70,7 +70,8 @@ using ControlElementwiseOpsFusionFn =
/// loop in the generic op.
void populateFoldReshapeOpsByExpansionPatterns(
RewritePatternSet &patterns,
- ControlElementwiseOpsFusionFn controlFoldingReshapes = skipUnitDimReshape);
+ const ControlElementwiseOpsFusionFn &controlFoldingReshapes =
+ skipUnitDimReshape);
/// Patterns to fold a collapsing (expanding) tensor_reshape operation with its
/// producer (consumer) generic operation by linearizing the indexing map used
@@ -356,7 +357,7 @@ struct PromotionInfo {
};
FailureOr<PromotionInfo>
promoteSubviewAsNewBuffer(OpBuilder &b, Location loc, memref::SubViewOp subView,
- AllocBufferCallbackFn allocationFn,
+ const AllocBufferCallbackFn &allocationFn,
DataLayout &layout);
/// Promotes the `subViews` into a new buffer allocated at the insertion point
@@ -370,7 +371,7 @@ promoteSubviewAsNewBuffer(OpBuilder &b, Location loc, memref::SubViewOp subView,
/// Returns the modified linalg op (the modification happens in place) as well
/// as all the copy ops created.
FailureOr<LinalgOp> promoteSubViews(OpBuilder &b, LinalgOp op,
- LinalgPromotionOptions options);
+ const LinalgPromotionOptions &options);
/// Emit a suitable vector form for a Linalg op with fully static shape.
LogicalResult vectorizeLinalgOp(OpBuilder &builder, Operation *op,
@@ -437,7 +438,7 @@ struct LinalgTransformationFilter {
Optional<StringAttr> replacement = None);
explicit LinalgTransformationFilter(
- FilterFunction f, ArrayRef<StringAttr> matchDisjunction = {},
+ const FilterFunction &f, ArrayRef<StringAttr> matchDisjunction = {},
Optional<StringAttr> replacement = None);
LinalgTransformationFilter(LinalgTransformationFilter &&) = default;
@@ -1180,7 +1181,7 @@ struct LinalgLoweringPattern : public RewritePattern {
/// linalg.generic ops.
void populateLinalgNamedOpsGeneralizationPatterns(
RewritePatternSet &patterns,
- LinalgTransformationFilter filter = LinalgTransformationFilter());
+ const LinalgTransformationFilter &filter = LinalgTransformationFilter());
/// Linalg decompose convolutions patterns
@@ -1189,7 +1190,7 @@ void populateLinalgNamedOpsGeneralizationPatterns(
/// vectorize the low-D convolution ops.
void populateDecomposeConvolutionPatterns(
RewritePatternSet &patterns,
- LinalgTransformationFilter filter = LinalgTransformationFilter(),
+ const LinalgTransformationFilter &filter = LinalgTransformationFilter(),
PatternBenefit benefit = 1);
/// Linalg distribution patterns
diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h
index 28a4261b9b80..3fa166c056ae 100644
--- a/mlir/include/mlir/IR/AffineMap.h
+++ b/mlir/include/mlir/IR/AffineMap.h
@@ -182,7 +182,7 @@ class AffineMap {
/// Walk all of the AffineExpr's in this mapping. Each node in an expression
/// tree is visited in postorder.
- void walkExprs(std::function<void(AffineExpr)> callback) const;
+ void walkExprs(llvm::function_ref<void(AffineExpr)> callback) const;
/// This method substitutes any uses of dimensions and symbols (e.g.
/// dim#0 with dimReplacements[0]) in subexpressions and returns the modified
diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h
index d7dc51189d6a..0ee8057d1e66 100644
--- a/mlir/include/mlir/IR/Dialect.h
+++ b/mlir/include/mlir/IR/Dialect.h
@@ -317,7 +317,8 @@ class DialectRegistry {
/// Add a new dialect constructor to the registry. The constructor must be
/// calling MLIRContext::getOrLoadDialect in order for the context to take
/// ownership of the dialect and for delayed interface registration to happen.
- void insert(TypeID typeID, StringRef name, DialectAllocatorFunction ctor);
+ void insert(TypeID typeID, StringRef name,
+ const DialectAllocatorFunction &ctor);
/// Return an allocation function for constructing the dialect identified by
/// its namespace, or nullptr if the namespace is not in this registry.
@@ -397,13 +398,13 @@ class DialectRegistry {
/// Add an interface constructed with the given allocation function to the
/// dialect identified by its namespace.
void addDialectInterface(StringRef dialectName, TypeID interfaceTypeID,
- DialectInterfaceAllocatorFunction allocator);
+ const DialectInterfaceAllocatorFunction &allocator);
/// Add an attribute/operation/type interface constructible with the given
/// allocation function to the dialect identified by its namespace.
void addObjectInterface(StringRef dialectName, TypeID objectID,
TypeID interfaceTypeID,
- ObjectInterfaceAllocatorFunction allocator);
+ const ObjectInterfaceAllocatorFunction &allocator);
/// Add an external model for an attribute/type interface to the dialect
/// identified by its namespace.
diff --git a/mlir/include/mlir/Reducer/ReductionNode.h b/mlir/include/mlir/Reducer/ReductionNode.h
index 442bc59589f3..814c88533b44 100644
--- a/mlir/include/mlir/Reducer/ReductionNode.h
+++ b/mlir/include/mlir/Reducer/ReductionNode.h
@@ -48,7 +48,7 @@ class ReductionNode {
using Range = std::pair<int, int>;
- ReductionNode(ReductionNode *parent, std::vector<Range> range,
+ ReductionNode(ReductionNode *parent, const std::vector<Range> &range,
llvm::SpecificBumpPtrAllocator<ReductionNode> &allocator);
ReductionNode *getParent() const { return parent; }
diff --git a/mlir/include/mlir/TableGen/GenInfo.h b/mlir/include/mlir/TableGen/GenInfo.h
index 6a9364d3f7f5..bbba88f1c065 100644
--- a/mlir/include/mlir/TableGen/GenInfo.h
+++ b/mlir/include/mlir/TableGen/GenInfo.h
@@ -64,7 +64,8 @@ class GenInfo {
/// // At namespace scope.
/// static GenRegistration Print("print", "Print records", [](...){...});
struct GenRegistration {
- GenRegistration(StringRef arg, StringRef description, GenFunction function);
+ GenRegistration(StringRef arg, StringRef description,
+ const GenFunction &function);
};
} // namespace mlir
diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h
index 3c7fe6dad707..f55b1afe0947 100644
--- a/mlir/include/mlir/TableGen/Pattern.h
+++ b/mlir/include/mlir/TableGen/Pattern.h
@@ -398,7 +398,8 @@ class SymbolInfoMap {
// with index `argIndex` for operator `op`.
const_iterator findBoundSymbol(StringRef key, DagNode node,
const Operator &op, int argIndex) const;
- const_iterator findBoundSymbol(StringRef key, SymbolInfo symbolInfo) const;
+ const_iterator findBoundSymbol(StringRef key,
+ const SymbolInfo &symbolInfo) const;
// Returns the bounds of a range that includes all the elements which
// bind to the `key`.
diff --git a/mlir/include/mlir/Translation.h b/mlir/include/mlir/Translation.h
index 79220cc0d447..61b6fc803734 100644
--- a/mlir/include/mlir/Translation.h
+++ b/mlir/include/mlir/Translation.h
@@ -78,7 +78,7 @@ struct TranslateToMLIRRegistration {
struct TranslateFromMLIRRegistration {
TranslateFromMLIRRegistration(
llvm::StringRef name, const TranslateFromMLIRFunction &function,
- std::function<void(DialectRegistry &)> dialectRegistration =
+ const std::function<void(DialectRegistry &)> &dialectRegistration =
[](DialectRegistry &) {});
};
struct TranslateRegistration {
diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp
index e6c9863887b3..0672f25671ec 100644
--- a/mlir/lib/Analysis/LoopAnalysis.cpp
+++ b/mlir/lib/Analysis/LoopAnalysis.cpp
@@ -264,7 +264,7 @@ using VectorizableOpFun = std::function<bool(AffineForOp, Operation &)>;
static bool
isVectorizableLoopBodyWithOpCond(AffineForOp loop,
- VectorizableOpFun isVectorizableOp,
+ const VectorizableOpFun &isVectorizableOp,
NestedPattern &vectorTransferMatcher) {
auto *forOp = loop.getOperation();
diff --git a/mlir/lib/Analysis/NestedMatcher.cpp b/mlir/lib/Analysis/NestedMatcher.cpp
index a72b3cbb356a..8e6b2457b238 100644
--- a/mlir/lib/Analysis/NestedMatcher.cpp
+++ b/mlir/lib/Analysis/NestedMatcher.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/Analysis/NestedMatcher.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
@@ -55,7 +57,7 @@ void NestedPattern::freeNested() {
NestedPattern::NestedPattern(ArrayRef<NestedPattern> nested,
FilterFunctionType filter)
- : nestedPatterns(), filter(filter), skip(nullptr) {
+ : nestedPatterns(), filter(std::move(filter)), skip(nullptr) {
copyNestedToThis(nested);
}
@@ -132,13 +134,13 @@ namespace mlir {
namespace matcher {
NestedPattern Op(FilterFunctionType filter) {
- return NestedPattern({}, filter);
+ return NestedPattern({}, std::move(filter));
}
-NestedPattern If(NestedPattern child) {
+NestedPattern If(const NestedPattern &child) {
return NestedPattern(child, isAffineIfOp);
}
-NestedPattern If(FilterFunctionType filter, NestedPattern child) {
+NestedPattern If(const FilterFunctionType &filter, const NestedPattern &child) {
return NestedPattern(child, [filter](Operation &op) {
return isAffineIfOp(op) && filter(op);
});
@@ -146,23 +148,26 @@ NestedPattern If(FilterFunctionType filter, NestedPattern child) {
NestedPattern If(ArrayRef<NestedPattern> nested) {
return NestedPattern(nested, isAffineIfOp);
}
-NestedPattern If(FilterFunctionType filter, ArrayRef<NestedPattern> nested) {
+NestedPattern If(const FilterFunctionType &filter,
+ ArrayRef<NestedPattern> nested) {
return NestedPattern(nested, [filter](Operation &op) {
return isAffineIfOp(op) && filter(op);
});
}
-NestedPattern For(NestedPattern child) {
+NestedPattern For(const NestedPattern &child) {
return NestedPattern(child, isAffineForOp);
}
-NestedPattern For(FilterFunctionType filter, NestedPattern child) {
+NestedPattern For(const FilterFunctionType &filter,
+ const NestedPattern &child) {
return NestedPattern(
child, [=](Operation &op) { return isAffineForOp(op) && filter(op); });
}
NestedPattern For(ArrayRef<NestedPattern> nested) {
return NestedPattern(nested, isAffineForOp);
}
-NestedPattern For(FilterFunctionType filter, ArrayRef<NestedPattern> nested) {
+NestedPattern For(const FilterFunctionType &filter,
+ ArrayRef<NestedPattern> nested) {
return NestedPattern(
nested, [=](Operation &op) { return isAffineForOp(op) && filter(op); });
}
diff --git a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
index 6afd0815de2a..7de0b8156f44 100644
--- a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
+++ b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
@@ -17,7 +17,7 @@ using namespace mlir;
using namespace mlir::python::adaptors;
void mlir::python::populateDialectSparseTensorSubmodule(
- py::module m, const py::module &irModule) {
+ const py::module &m, const py::module &irModule) {
auto attributeClass = irModule.attr("Attribute");
py::enum_<MlirSparseTensorDimLevelType>(m, "DimLevelType", py::module_local())
diff --git a/mlir/lib/Bindings/Python/Dialects.h b/mlir/lib/Bindings/Python/Dialects.h
index 301d539275d0..c1725074c7a2 100644
--- a/mlir/lib/Bindings/Python/Dialects.h
+++ b/mlir/lib/Bindings/Python/Dialects.h
@@ -15,7 +15,7 @@ namespace mlir {
namespace python {
void populateDialectLinalgSubmodule(pybind11::module m);
-void populateDialectSparseTensorSubmodule(pybind11::module m,
+void populateDialectSparseTensorSubmodule(const pybind11::module &m,
const pybind11::module &irModule);
} // namespace python
diff --git a/mlir/lib/Bindings/Python/ExecutionEngineModule.cpp b/mlir/lib/Bindings/Python/ExecutionEngineModule.cpp
index 814209197505..9016900185c6 100644
--- a/mlir/lib/Bindings/Python/ExecutionEngineModule.cpp
+++ b/mlir/lib/Bindings/Python/ExecutionEngineModule.cpp
@@ -42,7 +42,7 @@ class PyExecutionEngine {
// Add an object to the list of referenced objects whose lifetime must exceed
// those of the ExecutionEngine.
- void addReferencedObject(pybind11::object obj) {
+ void addReferencedObject(const pybind11::object &obj) {
referencedObjects.push_back(obj);
}
diff --git a/mlir/lib/Bindings/Python/IRAffine.cpp b/mlir/lib/Bindings/Python/IRAffine.cpp
index c7cdc8243479..16c7ca335ac3 100644
--- a/mlir/lib/Bindings/Python/IRAffine.cpp
+++ b/mlir/lib/Bindings/Python/IRAffine.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "IRModule.h"
#include "PybindUtils.h"
@@ -30,7 +32,8 @@ static const char kDumpDocstring[] =
/// Throws errors in case of failure, using "action" to describe what the caller
/// was attempting to do.
template <typename PyType, typename CType>
-static void pyListToVector(py::list list, llvm::SmallVectorImpl<CType> &result,
+static void pyListToVector(const py::list &list,
+ llvm::SmallVectorImpl<CType> &result,
StringRef action) {
result.reserve(py::len(list));
for (py::handle item : list) {
@@ -203,7 +206,7 @@ class PyAffineAddExpr
static constexpr const char *pyClassName = "AffineAddExpr";
using PyConcreteAffineExpr::PyConcreteAffineExpr;
- static PyAffineAddExpr get(PyAffineExpr lhs, PyAffineExpr rhs) {
+ static PyAffineAddExpr get(PyAffineExpr lhs, const PyAffineExpr &rhs) {
MlirAffineExpr expr = mlirAffineAddExprGet(lhs, rhs);
return PyAffineAddExpr(lhs.getContext(), expr);
}
@@ -232,7 +235,7 @@ class PyAffineMulExpr
static constexpr const char *pyClassName = "AffineMulExpr";
using PyConcreteAffineExpr::PyConcreteAffineExpr;
- static PyAffineMulExpr get(PyAffineExpr lhs, PyAffineExpr rhs) {
+ static PyAffineMulExpr get(PyAffineExpr lhs, const PyAffineExpr &rhs) {
MlirAffineExpr expr = mlirAffineMulExprGet(lhs, rhs);
return PyAffineMulExpr(lhs.getContext(), expr);
}
@@ -261,7 +264,7 @@ class PyAffineModExpr
static constexpr const char *pyClassName = "AffineModExpr";
using PyConcreteAffineExpr::PyConcreteAffineExpr;
- static PyAffineModExpr get(PyAffineExpr lhs, PyAffineExpr rhs) {
+ static PyAffineModExpr get(PyAffineExpr lhs, const PyAffineExpr &rhs) {
MlirAffineExpr expr = mlirAffineModExprGet(lhs, rhs);
return PyAffineModExpr(lhs.getContext(), expr);
}
@@ -290,7 +293,7 @@ class PyAffineFloorDivExpr
static constexpr const char *pyClassName = "AffineFloorDivExpr";
using PyConcreteAffineExpr::PyConcreteAffineExpr;
- static PyAffineFloorDivExpr get(PyAffineExpr lhs, PyAffineExpr rhs) {
+ static PyAffineFloorDivExpr get(PyAffineExpr lhs, const PyAffineExpr &rhs) {
MlirAffineExpr expr = mlirAffineFloorDivExprGet(lhs, rhs);
return PyAffineFloorDivExpr(lhs.getContext(), expr);
}
@@ -319,7 +322,7 @@ class PyAffineCeilDivExpr
static constexpr const char *pyClassName = "AffineCeilDivExpr";
using PyConcreteAffineExpr::PyConcreteAffineExpr;
- static PyAffineCeilDivExpr get(PyAffineExpr lhs, PyAffineExpr rhs) {
+ static PyAffineCeilDivExpr get(PyAffineExpr lhs, const PyAffineExpr &rhs) {
MlirAffineExpr expr = mlirAffineCeilDivExprGet(lhs, rhs);
return PyAffineCeilDivExpr(lhs.getContext(), expr);
}
@@ -375,7 +378,7 @@ class PyAffineMapExprList
public:
static constexpr const char *pyClassName = "AffineExprList";
- PyAffineMapExprList(PyAffineMap map, intptr_t startIndex = 0,
+ PyAffineMapExprList(const PyAffineMap &map, intptr_t startIndex = 0,
intptr_t length = -1, intptr_t step = 1)
: Sliceable(startIndex,
length == -1 ? mlirAffineMapGetNumResults(map) : length,
@@ -423,7 +426,8 @@ namespace {
class PyIntegerSetConstraint {
public:
- PyIntegerSetConstraint(PyIntegerSet set, intptr_t pos) : set(set), pos(pos) {}
+ PyIntegerSetConstraint(PyIntegerSet set, intptr_t pos)
+ : set(std::move(set)), pos(pos) {}
PyAffineExpr getExpr() {
return PyAffineExpr(set.getContext(),
@@ -449,7 +453,7 @@ class PyIntegerSetConstraintList
public:
static constexpr const char *pyClassName = "IntegerSetConstraintList";
- PyIntegerSetConstraintList(PyIntegerSet set, intptr_t startIndex = 0,
+ PyIntegerSetConstraintList(const PyIntegerSet &set, intptr_t startIndex = 0,
intptr_t length = -1, intptr_t step = 1)
: Sliceable(startIndex,
length == -1 ? mlirIntegerSetGetNumConstraints(set) : length,
@@ -692,7 +696,8 @@ void mlir::python::populateIRAffine(py::module &m) {
DefaultingPyMlirContext context) {
SmallVector<MlirAffineExpr> affineExprs;
pyListToVector<PyAffineExpr, MlirAffineExpr>(
- exprs, affineExprs, "attempting to create an AffineMap");
+ std::move(exprs), affineExprs,
+ "attempting to create an AffineMap");
MlirAffineMap map =
mlirAffineMapGet(context->get(), dimCount, symbolCount,
affineExprs.size(), affineExprs.data());
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index 56d16b337c07..fd44ffe6ba5f 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "IRModule.h"
#include "PybindUtils.h"
@@ -116,7 +118,7 @@ class PyArrayAttribute : public PyConcreteAttribute<PyArrayAttribute> {
class PyArrayAttributeIterator {
public:
- PyArrayAttributeIterator(PyAttribute attr) : attr(attr) {}
+ PyArrayAttributeIterator(PyAttribute attr) : attr(std::move(attr)) {}
PyArrayAttributeIterator &dunderIter() { return *this; }
@@ -459,7 +461,7 @@ class PyDenseElementsAttribute
arrayInfo.format);
}
- static PyDenseElementsAttribute getSplat(PyType shapedType,
+ static PyDenseElementsAttribute getSplat(const PyType &shapedType,
PyAttribute &elementAttr) {
auto contextWrapper =
PyMlirContext::forContext(mlirTypeGetContext(shapedType));
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 864144226d45..ccdd159fd438 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -21,6 +21,8 @@
#include "llvm/ADT/SmallVector.h"
#include <pybind11/stl.h>
+#include <utility>
+
namespace py = pybind11;
using namespace mlir;
using namespace mlir::python;
@@ -176,7 +178,7 @@ static MlirStringRef toMlirStringRef(const std::string &s) {
struct PyGlobalDebugFlag {
static void set(py::object &o, bool enable) { mlirEnableGlobalDebug(enable); }
- static bool get(py::object) { return mlirIsGlobalDebugEnabled(); }
+ static bool get(const py::object &) { return mlirIsGlobalDebugEnabled(); }
static void bind(py::module &m) {
// Debug flags.
@@ -320,7 +322,7 @@ class PyBlockList {
throw SetPyError(PyExc_IndexError, "attempt to access out of bounds block");
}
- PyBlock appendBlock(py::args pyArgTypes) {
+ PyBlock appendBlock(const py::args &pyArgTypes) {
operation->checkValid();
llvm::SmallVector<MlirType, 4> argTypes;
argTypes.reserve(pyArgTypes.size());
@@ -503,9 +505,9 @@ pybind11::object PyMlirContext::contextEnter() {
return PyThreadContextEntry::pushContext(*this);
}
-void PyMlirContext::contextExit(pybind11::object excType,
- pybind11::object excVal,
- pybind11::object excTb) {
+void PyMlirContext::contextExit(const pybind11::object &excType,
+ const pybind11::object &excVal,
+ const pybind11::object &excTb) {
PyThreadContextEntry::popContext(*this);
}
@@ -689,8 +691,9 @@ py::object PyLocation::contextEnter() {
return PyThreadContextEntry::pushLocation(*this);
}
-void PyLocation::contextExit(py::object excType, py::object excVal,
- py::object excTb) {
+void PyLocation::contextExit(const pybind11::object &excType,
+ const pybind11::object &excVal,
+ const pybind11::object &excTb) {
PyThreadContextEntry::popLocation(*this);
}
@@ -945,11 +948,11 @@ py::object PyOperation::createFromCapsule(py::object capsule) {
}
py::object PyOperation::create(
- std::string name, llvm::Optional<std::vector<PyType *>> results,
+ const std::string &name, llvm::Optional<std::vector<PyType *>> results,
llvm::Optional<std::vector<PyValue *>> operands,
llvm::Optional<py::dict> attributes,
llvm::Optional<std::vector<PyBlock *>> successors, int regions,
- DefaultingPyLocation location, py::object maybeIp) {
+ DefaultingPyLocation location, const py::object &maybeIp) {
llvm::SmallVector<MlirValue, 4> mlirOperands;
llvm::SmallVector<MlirType, 4> mlirResults;
llvm::SmallVector<MlirBlock, 4> mlirSuccessors;
@@ -1105,7 +1108,7 @@ void PyOperation::erase() {
//------------------------------------------------------------------------------
py::object
-PyOpView::buildGeneric(py::object cls, py::list resultTypeList,
+PyOpView::buildGeneric(const py::object &cls, py::list resultTypeList,
py::list operandList,
llvm::Optional<py::dict> attributes,
llvm::Optional<std::vector<PyBlock *>> successors,
@@ -1359,16 +1362,17 @@ PyOpView::buildGeneric(py::object cls, py::list resultTypeList,
/*operands=*/std::move(operands),
/*attributes=*/std::move(attributes),
/*successors=*/std::move(successors),
- /*regions=*/*regions, location, maybeIp);
+ /*regions=*/*regions, location,
+ std::move(maybeIp));
}
-PyOpView::PyOpView(py::object operationObject)
+PyOpView::PyOpView(const py::object &operationObject)
// Casting through the PyOperationBase base-class and then back to the
// Operation lets us accept any PyOperationBase subclass.
: operation(py::cast<PyOperationBase &>(operationObject).getOperation()),
operationObject(operation.getRef().getObject()) {}
-py::object PyOpView::createRawSubclass(py::object userClass) {
+py::object PyOpView::createRawSubclass(const py::object &userClass) {
// This is... a little gross. The typical pattern is to have a pure python
// class that extends OpView like:
// class AddFOp(_cext.ir.OpView):
@@ -1465,9 +1469,9 @@ py::object PyInsertionPoint::contextEnter() {
return PyThreadContextEntry::pushInsertionPoint(*this);
}
-void PyInsertionPoint::contextExit(pybind11::object excType,
- pybind11::object excVal,
- pybind11::object excTb) {
+void PyInsertionPoint::contextExit(const pybind11::object &excType,
+ const pybind11::object &excVal,
+ const pybind11::object &excTb) {
PyThreadContextEntry::popInsertionPoint(*this);
}
@@ -1954,7 +1958,8 @@ class PyOpResultList : public Sliceable<PyOpResultList, PyOpResult> {
/// attributes, or by index, producing named attributes.
class PyOpAttributeMap {
public:
- PyOpAttributeMap(PyOperationRef operation) : operation(operation) {}
+ PyOpAttributeMap(PyOperationRef operation)
+ : operation(std::move(operation)) {}
PyAttribute dunderGetItemNamed(const std::string &name) {
MlirAttribute attr = mlirOperationGetAttributeByName(operation->get(),
@@ -1979,7 +1984,7 @@ class PyOpAttributeMap {
mlirIdentifierStr(namedAttr.name).length));
}
- void dunderSetItem(const std::string &name, PyAttribute attr) {
+ void dunderSetItem(const std::string &name, const PyAttribute &attr) {
mlirOperationSetAttributeByName(operation->get(), toMlirStringRef(name),
attr);
}
diff --git a/mlir/lib/Bindings/Python/IRInterfaces.cpp b/mlir/lib/Bindings/Python/IRInterfaces.cpp
index 564f36b9dac3..1fc66fef468c 100644
--- a/mlir/lib/Bindings/Python/IRInterfaces.cpp
+++ b/mlir/lib/Bindings/Python/IRInterfaces.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "IRModule.h"
#include "mlir-c/BuiltinAttributes.h"
#include "mlir-c/Interfaces.h"
@@ -58,7 +60,7 @@ class PyConcreteOpInterface {
/// operation or a subclass of OpView. In the latter case, only the static
/// methods of the interface are accessible to the caller.
PyConcreteOpInterface(py::object object, DefaultingPyMlirContext context)
- : obj(object) {
+ : obj(std::move(object)) {
try {
operation = &py::cast<PyOperation &>(obj);
} catch (py::cast_error &err) {
diff --git a/mlir/lib/Bindings/Python/IRModule.h b/mlir/lib/Bindings/Python/IRModule.h
index d5e8eb4aece5..df4aaebf3036 100644
--- a/mlir/lib/Bindings/Python/IRModule.h
+++ b/mlir/lib/Bindings/Python/IRModule.h
@@ -203,8 +203,9 @@ class PyMlirContext {
/// Enter and exit the context manager.
pybind11::object contextEnter();
- void contextExit(pybind11::object excType, pybind11::object excVal,
- pybind11::object excTb);
+ void contextExit(const pybind11::object &excType,
+ const pybind11::object &excVal,
+ const pybind11::object &excTb);
private:
PyMlirContext(MlirContext context);
@@ -316,8 +317,9 @@ class PyLocation : public BaseContextObject {
/// Enter and exit the context manager.
pybind11::object contextEnter();
- void contextExit(pybind11::object excType, pybind11::object excVal,
- pybind11::object excTb);
+ void contextExit(const pybind11::object &excType,
+ const pybind11::object &excVal,
+ const pybind11::object &excTb);
/// Gets a capsule wrapping the void* within the MlirLocation.
pybind11::object getCapsule();
@@ -482,11 +484,11 @@ class PyOperation : public PyOperationBase, public BaseContextObject {
/// Creates an operation. See corresponding python docstring.
static pybind11::object
- create(std::string name, llvm::Optional<std::vector<PyType *>> results,
+ create(const std::string &name, llvm::Optional<std::vector<PyType *>> results,
llvm::Optional<std::vector<PyValue *>> operands,
llvm::Optional<pybind11::dict> attributes,
llvm::Optional<std::vector<PyBlock *>> successors, int regions,
- DefaultingPyLocation location, pybind11::object ip);
+ DefaultingPyLocation location, const pybind11::object &ip);
/// Creates an OpView suitable for this operation.
pybind11::object createOpView();
@@ -524,15 +526,15 @@ class PyOperation : public PyOperationBase, public BaseContextObject {
/// python types.
class PyOpView : public PyOperationBase {
public:
- PyOpView(pybind11::object operationObject);
+ PyOpView(const pybind11::object &operationObject);
PyOperation &getOperation() override { return operation; }
- static pybind11::object createRawSubclass(pybind11::object userClass);
+ static pybind11::object createRawSubclass(const pybind11::object &userClass);
pybind11::object getOperationObject() { return operationObject; }
static pybind11::object
- buildGeneric(pybind11::object cls, pybind11::list resultTypeList,
+ buildGeneric(const pybind11::object &cls, pybind11::list resultTypeList,
pybind11::list operandList,
llvm::Optional<pybind11::dict> attributes,
llvm::Optional<std::vector<PyBlock *>> successors,
@@ -607,8 +609,9 @@ class PyInsertionPoint {
/// Enter and exit the context manager.
pybind11::object contextEnter();
- void contextExit(pybind11::object excType, pybind11::object excVal,
- pybind11::object excTb);
+ void contextExit(const pybind11::object &excType,
+ const pybind11::object &excVal,
+ const pybind11::object &excTb);
PyBlock &getBlock() { return block; }
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index 04262234ceaa..280f22b8525b 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -34,7 +34,7 @@ static SmallVector<StringRef> getNParallelLoopsAttrs(unsigned nParallelLoops) {
template <typename T>
static arith::ConstantOp
-createConstFromIntAttribute(Operation *op, std::string attrName,
+createConstFromIntAttribute(Operation *op, const std::string &attrName,
Type requiredAttrType, OpBuilder &rewriter) {
auto castedN = static_cast<T>(
op->getAttr(attrName).cast<IntegerAttr>().getValue().getSExtValue());
@@ -61,7 +61,38 @@ static mlir::SelectOp clampHelper(Location loc, Value arg,
return rewriter.create<mlir::SelectOp>(loc, largerThanMax, max, minOrArg);
}
-static SmallVector<Value> filterDynamicDims(SmallVector<Value> dynDims) {
+static mlir::Value applyPad(Location loc, Value input, ArrayRef<int64_t> pad,
+ Attribute padAttr, OpBuilder &rewriter) {
+ // Input should be padded if necessary.
+ if (llvm::all_of(pad, [](int64_t p) { return p == 0; }))
+ return input;
+
+ ShapedType inputTy = input.getType().cast<ShapedType>();
+ Type inputETy = inputTy.getElementType();
+ auto inputShape = inputTy.getShape();
+
+ assert((inputShape.size() * 2) == pad.size());
+
+ SmallVector<int64_t, 4> paddedShape;
+ SmallVector<OpFoldResult, 8> lowIndices;
+ SmallVector<OpFoldResult, 8> highIndices;
+ for (int i = 0, s = inputShape.size(); i < s; i++) {
+ auto lowPad = pad[i * 2];
+ auto highPad = pad[i * 2 + 1];
+ paddedShape.push_back(inputShape[i] + highPad + lowPad);
+ lowIndices.push_back(rewriter.getIndexAttr(lowPad));
+ highIndices.push_back(rewriter.getIndexAttr(highPad));
+ }
+
+ Value padValue = rewriter.create<arith::ConstantOp>(loc, padAttr);
+
+ return linalg::PadTensorOp::createPadScalarOp(
+ RankedTensorType::get(paddedShape, inputETy), input, padValue,
+ lowIndices, highIndices, /*nofold=*/false, loc, rewriter)
+ .result();
+}
+
+static SmallVector<Value> filterDynamicDims(const SmallVector<Value> &dynDims) {
SmallVector<Value> filteredDims;
for (auto dim : dynDims)
if (dim)
diff --git a/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp b/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp
index 641cd6f9324d..98f617082f21 100644
--- a/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp
+++ b/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/CommonFolders.h"
#include "mlir/IR/Builders.h"
@@ -192,8 +194,8 @@ OpFoldResult arith::AddIOp::fold(ArrayRef<Attribute> operands) {
if (matchPattern(getRhs(), m_Zero()))
return getLhs();
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a + b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](APInt a, const APInt &b) { return std::move(a) + b; });
}
void arith::AddIOp::getCanonicalizationPatterns(
@@ -214,8 +216,8 @@ OpFoldResult arith::SubIOp::fold(ArrayRef<Attribute> operands) {
if (matchPattern(getRhs(), m_Zero()))
return getLhs();
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a - b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](APInt a, const APInt &b) { return std::move(a) - b; });
}
void arith::SubIOp::getCanonicalizationPatterns(
@@ -239,8 +241,8 @@ OpFoldResult arith::MulIOp::fold(ArrayRef<Attribute> operands) {
// TODO: Handle the overflow case.
// default folder
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a * b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](const APInt &a, const APInt &b) { return a * b; });
}
//===----------------------------------------------------------------------===//
@@ -250,13 +252,14 @@ OpFoldResult arith::MulIOp::fold(ArrayRef<Attribute> operands) {
OpFoldResult arith::DivUIOp::fold(ArrayRef<Attribute> operands) {
// Don't fold if it would require a division by zero.
bool div0 = false;
- auto result = constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, APInt b) {
- if (div0 || !b) {
- div0 = true;
- return a;
- }
- return a.udiv(b);
- });
+ auto result =
+ constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
+ if (div0 || !b) {
+ div0 = true;
+ return a;
+ }
+ return a.udiv(b);
+ });
// Fold out division by one. Assumes all tensors of all ones are splats.
if (auto rhs = operands[1].dyn_cast_or_null<IntegerAttr>()) {
@@ -277,13 +280,14 @@ OpFoldResult arith::DivUIOp::fold(ArrayRef<Attribute> operands) {
OpFoldResult arith::DivSIOp::fold(ArrayRef<Attribute> operands) {
// Don't fold if it would overflow or if it requires a division by zero.
bool overflowOrDiv0 = false;
- auto result = constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, APInt b) {
- if (overflowOrDiv0 || !b) {
- overflowOrDiv0 = true;
- return a;
- }
- return a.sdiv_ov(b, overflowOrDiv0);
- });
+ auto result =
+ constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
+ if (overflowOrDiv0 || !b) {
+ overflowOrDiv0 = true;
+ return a;
+ }
+ return a.sdiv_ov(b, overflowOrDiv0);
+ });
// Fold out division by one. Assumes all tensors of all ones are splats.
if (auto rhs = operands[1].dyn_cast_or_null<IntegerAttr>()) {
@@ -301,7 +305,8 @@ OpFoldResult arith::DivSIOp::fold(ArrayRef<Attribute> operands) {
// Ceil and floor division folding helpers
//===----------------------------------------------------------------------===//
-static APInt signedCeilNonnegInputs(APInt a, APInt b, bool &overflow) {
+static APInt signedCeilNonnegInputs(const APInt &a, const APInt &b,
+ bool &overflow) {
// Returns (a-1)/b + 1
APInt one(a.getBitWidth(), 1, true); // Signed value 1.
APInt val = a.ssub_ov(one, overflow).sdiv_ov(b, overflow);
@@ -314,17 +319,18 @@ static APInt signedCeilNonnegInputs(APInt a, APInt b, bool &overflow) {
OpFoldResult arith::CeilDivUIOp::fold(ArrayRef<Attribute> operands) {
bool overflowOrDiv0 = false;
- auto result = constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, APInt b) {
- if (overflowOrDiv0 || !b) {
- overflowOrDiv0 = true;
- return a;
- }
- APInt quotient = a.udiv(b);
- if (!a.urem(b))
- return quotient;
- APInt one(a.getBitWidth(), 1, true);
- return quotient.uadd_ov(one, overflowOrDiv0);
- });
+ auto result =
+ constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
+ if (overflowOrDiv0 || !b) {
+ overflowOrDiv0 = true;
+ return a;
+ }
+ APInt quotient = a.udiv(b);
+ if (!a.urem(b))
+ return quotient;
+ APInt one(a.getBitWidth(), 1, true);
+ return quotient.uadd_ov(one, overflowOrDiv0);
+ });
// Fold out ceil division by one. Assumes all tensors of all ones are
// splats.
if (auto rhs = operands[1].dyn_cast_or_null<IntegerAttr>()) {
@@ -345,34 +351,35 @@ OpFoldResult arith::CeilDivUIOp::fold(ArrayRef<Attribute> operands) {
OpFoldResult arith::CeilDivSIOp::fold(ArrayRef<Attribute> operands) {
// Don't fold if it would overflow or if it requires a division by zero.
bool overflowOrDiv0 = false;
- auto result = constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, APInt b) {
- if (overflowOrDiv0 || !b) {
- overflowOrDiv0 = true;
- return a;
- }
- unsigned bits = a.getBitWidth();
- APInt zero = APInt::getZero(bits);
- if (a.sgt(zero) && b.sgt(zero)) {
- // Both positive, return ceil(a, b).
- return signedCeilNonnegInputs(a, b, overflowOrDiv0);
- }
- if (a.slt(zero) && b.slt(zero)) {
- // Both negative, return ceil(-a, -b).
- APInt posA = zero.ssub_ov(a, overflowOrDiv0);
- APInt posB = zero.ssub_ov(b, overflowOrDiv0);
- return signedCeilNonnegInputs(posA, posB, overflowOrDiv0);
- }
- if (a.slt(zero) && b.sgt(zero)) {
- // A is negative, b is positive, return - ( -a / b).
- APInt posA = zero.ssub_ov(a, overflowOrDiv0);
- APInt div = posA.sdiv_ov(b, overflowOrDiv0);
- return zero.ssub_ov(div, overflowOrDiv0);
- }
- // A is positive (or zero), b is negative, return - (a / -b).
- APInt posB = zero.ssub_ov(b, overflowOrDiv0);
- APInt div = a.sdiv_ov(posB, overflowOrDiv0);
- return zero.ssub_ov(div, overflowOrDiv0);
- });
+ auto result =
+ constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
+ if (overflowOrDiv0 || !b) {
+ overflowOrDiv0 = true;
+ return a;
+ }
+ unsigned bits = a.getBitWidth();
+ APInt zero = APInt::getZero(bits);
+ if (a.sgt(zero) && b.sgt(zero)) {
+ // Both positive, return ceil(a, b).
+ return signedCeilNonnegInputs(a, b, overflowOrDiv0);
+ }
+ if (a.slt(zero) && b.slt(zero)) {
+ // Both negative, return ceil(-a, -b).
+ APInt posA = zero.ssub_ov(a, overflowOrDiv0);
+ APInt posB = zero.ssub_ov(b, overflowOrDiv0);
+ return signedCeilNonnegInputs(posA, posB, overflowOrDiv0);
+ }
+ if (a.slt(zero) && b.sgt(zero)) {
+ // A is negative, b is positive, return - ( -a / b).
+ APInt posA = zero.ssub_ov(a, overflowOrDiv0);
+ APInt div = posA.sdiv_ov(b, overflowOrDiv0);
+ return zero.ssub_ov(div, overflowOrDiv0);
+ }
+ // A is positive (or zero), b is negative, return - (a / -b).
+ APInt posB = zero.ssub_ov(b, overflowOrDiv0);
+ APInt div = a.sdiv_ov(posB, overflowOrDiv0);
+ return zero.ssub_ov(div, overflowOrDiv0);
+ });
// Fold out ceil division by one. Assumes all tensors of all ones are
// splats.
@@ -394,34 +401,35 @@ OpFoldResult arith::CeilDivSIOp::fold(ArrayRef<Attribute> operands) {
OpFoldResult arith::FloorDivSIOp::fold(ArrayRef<Attribute> operands) {
// Don't fold if it would overflow or if it requires a division by zero.
bool overflowOrDiv0 = false;
- auto result = constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, APInt b) {
- if (overflowOrDiv0 || !b) {
- overflowOrDiv0 = true;
- return a;
- }
- unsigned bits = a.getBitWidth();
- APInt zero = APInt::getZero(bits);
- if (a.sge(zero) && b.sgt(zero)) {
- // Both positive (or a is zero), return a / b.
- return a.sdiv_ov(b, overflowOrDiv0);
- }
- if (a.sle(zero) && b.slt(zero)) {
- // Both negative (or a is zero), return -a / -b.
- APInt posA = zero.ssub_ov(a, overflowOrDiv0);
- APInt posB = zero.ssub_ov(b, overflowOrDiv0);
- return posA.sdiv_ov(posB, overflowOrDiv0);
- }
- if (a.slt(zero) && b.sgt(zero)) {
- // A is negative, b is positive, return - ceil(-a, b).
- APInt posA = zero.ssub_ov(a, overflowOrDiv0);
- APInt ceil = signedCeilNonnegInputs(posA, b, overflowOrDiv0);
- return zero.ssub_ov(ceil, overflowOrDiv0);
- }
- // A is positive, b is negative, return - ceil(a, -b).
- APInt posB = zero.ssub_ov(b, overflowOrDiv0);
- APInt ceil = signedCeilNonnegInputs(a, posB, overflowOrDiv0);
- return zero.ssub_ov(ceil, overflowOrDiv0);
- });
+ auto result =
+ constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
+ if (overflowOrDiv0 || !b) {
+ overflowOrDiv0 = true;
+ return a;
+ }
+ unsigned bits = a.getBitWidth();
+ APInt zero = APInt::getZero(bits);
+ if (a.sge(zero) && b.sgt(zero)) {
+ // Both positive (or a is zero), return a / b.
+ return a.sdiv_ov(b, overflowOrDiv0);
+ }
+ if (a.sle(zero) && b.slt(zero)) {
+ // Both negative (or a is zero), return -a / -b.
+ APInt posA = zero.ssub_ov(a, overflowOrDiv0);
+ APInt posB = zero.ssub_ov(b, overflowOrDiv0);
+ return posA.sdiv_ov(posB, overflowOrDiv0);
+ }
+ if (a.slt(zero) && b.sgt(zero)) {
+ // A is negative, b is positive, return - ceil(-a, b).
+ APInt posA = zero.ssub_ov(a, overflowOrDiv0);
+ APInt ceil = signedCeilNonnegInputs(posA, b, overflowOrDiv0);
+ return zero.ssub_ov(ceil, overflowOrDiv0);
+ }
+ // A is positive, b is negative, return - ceil(a, -b).
+ APInt posB = zero.ssub_ov(b, overflowOrDiv0);
+ APInt ceil = signedCeilNonnegInputs(a, posB, overflowOrDiv0);
+ return zero.ssub_ov(ceil, overflowOrDiv0);
+ });
// Fold out floor division by one. Assumes all tensors of all ones are
// splats.
@@ -497,8 +505,8 @@ OpFoldResult arith::AndIOp::fold(ArrayRef<Attribute> operands) {
if (matchPattern(getRhs(), m_ConstantInt(&intValue)) && intValue.isAllOnes())
return getLhs();
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a & b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](APInt a, const APInt &b) { return std::move(a) & b; });
}
//===----------------------------------------------------------------------===//
@@ -514,8 +522,8 @@ OpFoldResult arith::OrIOp::fold(ArrayRef<Attribute> operands) {
if (rhsAttr.getValue().isAllOnes())
return rhsAttr;
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a | b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](APInt a, const APInt &b) { return std::move(a) | b; });
}
//===----------------------------------------------------------------------===//
@@ -530,8 +538,8 @@ OpFoldResult arith::XOrIOp::fold(ArrayRef<Attribute> operands) {
if (getLhs() == getRhs())
return Builder(getContext()).getZeroAttr(getType());
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a ^ b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](APInt a, const APInt &b) { return std::move(a) ^ b; });
}
void arith::XOrIOp::getCanonicalizationPatterns(
@@ -545,7 +553,7 @@ void arith::XOrIOp::getCanonicalizationPatterns(
OpFoldResult arith::AddFOp::fold(ArrayRef<Attribute> operands) {
return constFoldBinaryOp<FloatAttr>(
- operands, [](APFloat a, APFloat b) { return a + b; });
+ operands, [](const APFloat &a, const APFloat &b) { return a + b; });
}
//===----------------------------------------------------------------------===//
@@ -554,7 +562,7 @@ OpFoldResult arith::AddFOp::fold(ArrayRef<Attribute> operands) {
OpFoldResult arith::SubFOp::fold(ArrayRef<Attribute> operands) {
return constFoldBinaryOp<FloatAttr>(
- operands, [](APFloat a, APFloat b) { return a - b; });
+ operands, [](const APFloat &a, const APFloat &b) { return a - b; });
}
//===----------------------------------------------------------------------===//
@@ -579,8 +587,10 @@ OpFoldResult MaxSIOp::fold(ArrayRef<Attribute> operands) {
intValue.isMinSignedValue())
return getLhs();
- return constFoldBinaryOp<IntegerAttr>(
- operands, [](APInt a, APInt b) { return llvm::APIntOps::smax(a, b); });
+ return constFoldBinaryOp<IntegerAttr>(operands,
+ [](const APInt &a, const APInt &b) {
+ return llvm::APIntOps::smax(a, b);
+ });
}
//===----------------------------------------------------------------------===//
@@ -603,8 +613,10 @@ OpFoldResult MaxUIOp::fold(ArrayRef<Attribute> operands) {
if (matchPattern(getRhs(), m_ConstantInt(&intValue)) && intValue.isMinValue())
return getLhs();
- return constFoldBinaryOp<IntegerAttr>(
- operands, [](APInt a, APInt b) { return llvm::APIntOps::umax(a, b); });
+ return constFoldBinaryOp<IntegerAttr>(operands,
+ [](const APInt &a, const APInt &b) {
+ return llvm::APIntOps::umax(a, b);
+ });
}
//===----------------------------------------------------------------------===//
@@ -629,8 +641,10 @@ OpFoldResult MinSIOp::fold(ArrayRef<Attribute> operands) {
intValue.isMaxSignedValue())
return getLhs();
- return constFoldBinaryOp<IntegerAttr>(
- operands, [](APInt a, APInt b) { return llvm::APIntOps::smin(a, b); });
+ return constFoldBinaryOp<IntegerAttr>(operands,
+ [](const APInt &a, const APInt &b) {
+ return llvm::APIntOps::smin(a, b);
+ });
}
//===----------------------------------------------------------------------===//
@@ -653,8 +667,10 @@ OpFoldResult MinUIOp::fold(ArrayRef<Attribute> operands) {
if (matchPattern(getRhs(), m_ConstantInt(&intValue)) && intValue.isMaxValue())
return getLhs();
- return constFoldBinaryOp<IntegerAttr>(
- operands, [](APInt a, APInt b) { return llvm::APIntOps::umin(a, b); });
+ return constFoldBinaryOp<IntegerAttr>(operands,
+ [](const APInt &a, const APInt &b) {
+ return llvm::APIntOps::umin(a, b);
+ });
}
//===----------------------------------------------------------------------===//
@@ -663,7 +679,7 @@ OpFoldResult MinUIOp::fold(ArrayRef<Attribute> operands) {
OpFoldResult arith::MulFOp::fold(ArrayRef<Attribute> operands) {
return constFoldBinaryOp<FloatAttr>(
- operands, [](APFloat a, APFloat b) { return a * b; });
+ operands, [](const APFloat &a, const APFloat &b) { return a * b; });
}
//===----------------------------------------------------------------------===//
@@ -672,7 +688,7 @@ OpFoldResult arith::MulFOp::fold(ArrayRef<Attribute> operands) {
OpFoldResult arith::DivFOp::fold(ArrayRef<Attribute> operands) {
return constFoldBinaryOp<FloatAttr>(
- operands, [](APFloat a, APFloat b) { return a / b; });
+ operands, [](const APFloat &a, const APFloat &b) { return a / b; });
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
index f0b4244c9f4f..db09c11574ac 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
@@ -10,6 +10,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "PassDetail.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/Async/IR/Async.h"
@@ -111,7 +113,7 @@ struct AsyncParallelForRewrite : public OpRewritePattern<scf::ParallelOp> {
AsyncMinTaskSizeComputationFunction computeMinTaskSize)
: OpRewritePattern(ctx), asyncDispatch(asyncDispatch),
numWorkerThreads(numWorkerThreads),
- computeMinTaskSize(computeMinTaskSize) {}
+ computeMinTaskSize(std::move(computeMinTaskSize)) {}
LogicalResult matchAndRewrite(scf::ParallelOp op,
PatternRewriter &rewriter) const override;
@@ -244,7 +246,7 @@ getParallelComputeFunctionType(scf::ParallelOp op, PatternRewriter &rewriter) {
// Create a parallel compute fuction from the parallel operation.
static ParallelComputeFunction createParallelComputeFunction(
- scf::ParallelOp op, ParallelComputeFunctionBounds bounds,
+ scf::ParallelOp op, const ParallelComputeFunctionBounds &bounds,
unsigned numBlockAlignedInnerLoops, PatternRewriter &rewriter) {
OpBuilder::InsertionGuard guard(rewriter);
ImplicitLocOpBuilder b(op.getLoc(), rewriter);
@@ -902,7 +904,7 @@ std::unique_ptr<Pass> mlir::createAsyncParallelForPass(bool asyncDispatch,
void mlir::async::populateAsyncParallelForPatterns(
RewritePatternSet &patterns, bool asyncDispatch, int32_t numWorkerThreads,
- AsyncMinTaskSizeComputationFunction computeMinTaskSize) {
+ const AsyncMinTaskSizeComputationFunction &computeMinTaskSize) {
MLIRContext *ctx = patterns.getContext();
patterns.add<AsyncParallelForRewrite>(ctx, asyncDispatch, numWorkerThreads,
computeMinTaskSize);
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
index 49a39b621f37..33c8793cbc25 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
@@ -64,7 +64,7 @@ using namespace mlir;
/// Walks over all immediate return-like terminators in the given region.
static LogicalResult
walkReturnOperations(Region *region,
- std::function<LogicalResult(Operation *)> func) {
+ llvm::function_ref<LogicalResult(Operation *)> func) {
for (Block &block : *region) {
Operation *terminator = block.getTerminator();
// Skip non region-return-like terminators.
diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
index 1a03867a18cb..ac5272348438 100644
--- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
@@ -78,7 +78,8 @@ static bool isSinkingBeneficiary(Operation *op) {
/// is updated with results that will be available after sinking the identified
/// ops.
static bool
-extractBeneficiaryOps(Operation *op, SetVector<Value> existingDependencies,
+extractBeneficiaryOps(Operation *op,
+ const SetVector<Value> &existingDependencies,
SetVector<Operation *> &beneficiaryOps,
llvm::SmallPtrSetImpl<Value> &availableValues) {
if (beneficiaryOps.count(op))
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 5b64a29974ce..66157371f30c 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -313,7 +313,7 @@ static void printSwitchOpCases(OpAsmPrinter &p, SwitchOp op, Type flagType,
ElementsAttr caseValues,
SuccessorRange caseDestinations,
OperandRangeRange caseOperands,
- TypeRangeRange caseOperandTypes) {
+ const TypeRangeRange &caseOperandTypes) {
if (!caseValues)
return;
@@ -361,7 +361,8 @@ SwitchOp::getMutableSuccessorOperands(unsigned index) {
LogicalResult verifySymbolAttribute(
Operation *op, StringRef attributeName,
- std::function<LogicalResult(Operation *, SymbolRefAttr)> verifySymbolType) {
+ llvm::function_ref<LogicalResult(Operation *, SymbolRefAttr)>
+ verifySymbolType) {
if (Attribute attribute = op->getAttr(attributeName)) {
// The attribute is already verified to be a symbol ref array attribute via
// a constraint in the operation definition.
diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp
index 31ebbac73a27..f7d22251eadb 100644
--- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp
+++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp
@@ -285,7 +285,7 @@ bool mlir::linalg::comprehensive_bufferize::BufferizationState::isValueRead(
llvm::SetVector<Value>
mlir::linalg::comprehensive_bufferize::BufferizationState::
findValueInReverseUseDefChain(Value value,
- std::function<bool(Value)> condition) {
+ llvm::function_ref<bool(Value)> condition) {
llvm::SetVector<Value> result, workingSet;
workingSet.insert(value);
diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/SCFInterfaceImpl.cpp b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/SCFInterfaceImpl.cpp
index 8a2630c29b7f..5db5deb6aee6 100644
--- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/SCFInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/SCFInterfaceImpl.cpp
@@ -296,7 +296,7 @@ struct ForOpInterface
// Given a range of values, apply `func` to those marked in `indices`.
// Otherwise, store the unmodified value in the result vector.
auto convert = [&](ValueRange values,
- std::function<Value(Value, int64_t)> func) {
+ llvm::function_ref<Value(Value, int64_t)> func) {
SmallVector<Value> result;
for (const auto &it : llvm::enumerate(values)) {
size_t idx = it.index();
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index e7ddee95f387..fe3363d7d0de 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -50,7 +50,7 @@ template <typename NamedStructuredOpType>
static void fillStructuredOpRegion(
OpBuilder &opBuilder, Region ®ion, TypeRange inputTypes,
TypeRange outputTypes,
- std::function<void(unsigned, unsigned)> errorHandler = nullptr);
+ llvm::function_ref<void(unsigned, unsigned)> errorHandler = nullptr);
/// Generic entry point to create both the region and the block of a LinalgOp.
template <typename NamedStructuredOpType>
@@ -323,7 +323,7 @@ class RegionBuilderHelper {
builder.create<YieldOp>(first.getLoc(), values);
}
- Value constant(std::string value) {
+ Value constant(const std::string &value) {
OpBuilder builder = getBuilder();
Location loc = builder.getUnknownLoc();
Attribute valueAttr = parseAttribute(value, builder.getContext());
@@ -2406,10 +2406,10 @@ std::string mlir::linalg::generateLibraryCallName(Operation *op) {
/// to the elemental types of `inputTypes` and `outputTypes`, which are asserted
/// to be ShapedType.
template <typename NamedStructuredOpType>
-static void
-fillStructuredOpRegion(OpBuilder &opBuilder, Region ®ion,
- TypeRange inputTypes, TypeRange outputTypes,
- std::function<void(unsigned, unsigned)> errorHandler) {
+static void fillStructuredOpRegion(
+ OpBuilder &opBuilder, Region ®ion, TypeRange inputTypes,
+ TypeRange outputTypes,
+ llvm::function_ref<void(unsigned, unsigned)> errorHandler) {
assert(llvm::all_of(outputTypes, [](Type t) { return t.isa<ShapedType>(); }));
// TODO: atm all operands go through getElementTypeOrSelf,
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
index a20da7ffa207..8812dd4dff76 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
@@ -16,6 +16,7 @@
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include <iterator>
#include <memory>
+#include <utility>
using namespace mlir;
using namespace mlir::linalg;
@@ -97,7 +98,7 @@ struct FunctionNonEntryBlockConversion : public ConversionPattern {
: ConversionPattern(converter, MatchTraitOpTypeTag(),
TypeID::get<OpTrait::FunctionLike>(), /*benefit=*/1,
ctx),
- blockArgsToDetensor(blockArgsToDetensor) {}
+ blockArgsToDetensor(std::move(blockArgsToDetensor)) {}
LogicalResult
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Distribution.cpp b/mlir/lib/Dialect/Linalg/Transforms/Distribution.cpp
index e951d6882022..692df291b2f6 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Distribution.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Distribution.cpp
@@ -11,6 +11,8 @@
//
//===----------------------------------------------------------------------===//
//
+#include <utility>
+
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/Dialect/Linalg/Utils/Utils.h"
#include "mlir/IR/MLIRContext.h"
@@ -31,8 +33,8 @@ struct DistributeTiledLoopPattern
DistributeTiledLoopPattern(MLIRContext *context,
LinalgLoopDistributionOptions options,
LinalgTransformationFilter marker)
- : OpRewritePattern<linalg::TiledLoopOp>(context), options(options),
- marker(marker) {}
+ : OpRewritePattern<linalg::TiledLoopOp>(context),
+ options(std::move(options)), marker(std::move(marker)) {}
LogicalResult matchAndRewrite(linalg::TiledLoopOp op,
PatternRewriter &rewriter) const override {
if (failed(marker.checkAndNotify(rewriter, op)))
diff --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
index 34ee7a9714f8..795a23d7b1d8 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
@@ -9,6 +9,8 @@
// This file implements the linalg dialect Fusion on tensors operations pass.
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "PassDetail.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
@@ -1078,7 +1080,7 @@ class FoldWithProducerReshapeOpByExpansion
MLIRContext *context, ControlElementwiseOpsFusionFn foldReshapes,
PatternBenefit benefit = 1)
: OpRewritePattern<GenericOp>(context, benefit),
- controlFoldingReshapes(foldReshapes) {}
+ controlFoldingReshapes(std::move(foldReshapes)) {}
LogicalResult matchAndRewrite(GenericOp genericOp,
PatternRewriter &rewriter) const override {
@@ -1181,7 +1183,7 @@ struct FoldReshapeWithGenericOpByExpansion
MLIRContext *context, ControlElementwiseOpsFusionFn foldReshapes,
PatternBenefit benefit = 1)
: OpRewritePattern<tensor::ExpandShapeOp>(context, benefit),
- controlFoldingReshapes(foldReshapes) {}
+ controlFoldingReshapes(std::move(foldReshapes)) {}
LogicalResult matchAndRewrite(tensor::ExpandShapeOp reshapeOp,
PatternRewriter &rewriter) const override {
@@ -1755,7 +1757,7 @@ void mlir::linalg::populateFoldUnitDimsReshapeOpsByLinearizationPatterns(
void mlir::linalg::populateFoldReshapeOpsByExpansionPatterns(
RewritePatternSet &patterns,
- ControlElementwiseOpsFusionFn controlFoldingReshapes) {
+ const ControlElementwiseOpsFusionFn &controlFoldingReshapes) {
patterns.add<FoldReshapeWithGenericOpByExpansion>(patterns.getContext(),
controlFoldingReshapes);
patterns.add<FoldWithProducerReshapeOpByExpansion>(patterns.getContext(),
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
index 85add4f8dc9d..a42ac8d81c4b 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
@@ -78,7 +78,7 @@ void LinalgGeneralizationPass::runOnFunction() {
}
void mlir::linalg::populateLinalgNamedOpsGeneralizationPatterns(
- RewritePatternSet &patterns, LinalgTransformationFilter marker) {
+ RewritePatternSet &patterns, const LinalgTransformationFilter &marker) {
patterns.add<LinalgGeneralizationPattern>(patterns.getContext(), marker);
}
diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
index d9e4c578b6d6..136f38feedf3 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
@@ -11,6 +11,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "PassDetail.h"
#include "mlir/Analysis/SliceAnalysis.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
@@ -46,7 +48,7 @@ struct LinalgStrategyTileAndFusePass
LinalgStrategyTileAndFusePass(StringRef opName,
LinalgTilingAndFusionOptions opt,
LinalgTransformationFilter filt)
- : options(opt), filter(filt) {
+ : options(std::move(opt)), filter(std::move(filt)) {
this->anchorOpName.setValue(opName.str());
}
@@ -82,7 +84,7 @@ struct LinalgStrategyTilePass
LinalgStrategyTilePass(StringRef opName, LinalgTilingOptions opt,
LinalgTransformationFilter filt)
- : options(opt), filter(filt) {
+ : options(std::move(opt)), filter(std::move(filt)) {
this->anchorOpName.setValue(opName.str());
}
@@ -114,7 +116,7 @@ struct LinalgStrategyPadPass
LinalgStrategyPadPass(StringRef opName, LinalgPaddingOptions opt,
LinalgTransformationFilter filt)
- : options(opt), filter(filt) {
+ : options(std::move(opt)), filter(std::move(filt)) {
this->anchorOpName.setValue(opName.str());
}
@@ -146,7 +148,7 @@ struct LinalgStrategyGeneralizePass
LinalgStrategyGeneralizePass(StringRef opName,
LinalgTransformationFilter filter)
- : filter(filter) {
+ : filter(std::move(filter)) {
this->anchorOpName.setValue(opName.str());
}
@@ -179,7 +181,7 @@ struct LinalgStrategyDecomposePass
LinalgStrategyDecomposePass() = default;
LinalgStrategyDecomposePass(LinalgTransformationFilter filter)
- : filter(filter) {}
+ : filter(std::move(filter)) {}
void runOnFunction() override {
auto funcOp = getFunction();
@@ -205,7 +207,7 @@ struct LinalgStrategyInterchangePass
LinalgTransformationFilter filter)
: iteratorInterchange(iteratorInterchange.begin(),
iteratorInterchange.end()),
- filter(filter) {}
+ filter(std::move(filter)) {}
void runOnFunction() override {
auto funcOp = getFunction();
@@ -234,7 +236,7 @@ struct LinalgStrategyPromotePass
LinalgStrategyPromotePass(StringRef opName, LinalgPromotionOptions opt,
LinalgTransformationFilter filt)
- : options(opt), filter(filt) {
+ : options(std::move(opt)), filter(std::move(filt)) {
this->anchorOpName.setValue(opName.str());
}
@@ -267,7 +269,7 @@ struct LinalgStrategyVectorizePass
LinalgStrategyVectorizePass(StringRef opName, LinalgVectorizationOptions opt,
LinalgTransformationFilter filt,
bool padVectorize = false)
- : options(opt), filter(filt) {
+ : options(opt), filter(std::move(filt)) {
this->anchorOpName.setValue(opName.str());
this->vectorizePadding.setValue(padVectorize);
}
@@ -320,7 +322,7 @@ struct LinalgStrategyEnablePass
LinalgStrategyEnablePass(LinalgEnablingOptions opt,
LinalgTransformationFilter filt)
- : options(opt), filter(filt) {}
+ : options(opt), filter(std::move(filt)) {}
void runOnFunction() override {
auto funcOp = getFunction();
@@ -370,7 +372,7 @@ struct LinalgStrategyLowerVectorsPass
LinalgStrategyLowerVectorsPass(LinalgVectorLoweringOptions opt,
LinalgTransformationFilter filt)
- : options(opt), filter(filt) {}
+ : options(opt), filter(std::move(filt)) {}
void runOnFunction() override {
auto funcOp = getFunction();
@@ -446,53 +448,54 @@ struct LinalgStrategyRemoveMarkersPass
/// Create a LinalgStrategyTileAndFusePass.
std::unique_ptr<OperationPass<FuncOp>>
-mlir::createLinalgStrategyTileAndFusePass(StringRef opName,
- LinalgTilingAndFusionOptions options,
- LinalgTransformationFilter filter) {
+mlir::createLinalgStrategyTileAndFusePass(
+ StringRef opName, const LinalgTilingAndFusionOptions &options,
+ const LinalgTransformationFilter &filter) {
return std::make_unique<LinalgStrategyTileAndFusePass>(opName, options,
filter);
}
/// Create a LinalgStrategyTilePass.
std::unique_ptr<OperationPass<FuncOp>>
-mlir::createLinalgStrategyTilePass(StringRef opName, LinalgTilingOptions opt,
- LinalgTransformationFilter filter) {
+mlir::createLinalgStrategyTilePass(StringRef opName,
+ const LinalgTilingOptions &opt,
+ const LinalgTransformationFilter &filter) {
return std::make_unique<LinalgStrategyTilePass>(opName, opt, filter);
}
/// Create a LinalgStrategyPadPass.
std::unique_ptr<OperationPass<FuncOp>>
-mlir::createLinalgStrategyPadPass(StringRef opName, LinalgPaddingOptions opt,
- LinalgTransformationFilter filter) {
+mlir::createLinalgStrategyPadPass(StringRef opName,
+ const LinalgPaddingOptions &opt,
+ const LinalgTransformationFilter &filter) {
return std::make_unique<LinalgStrategyPadPass>(opName, opt, filter);
}
/// Create a LinalgStrategyPromotePass.
-std::unique_ptr<OperationPass<FuncOp>>
-mlir::createLinalgStrategyPromotePass(StringRef opName,
- LinalgPromotionOptions opt,
- LinalgTransformationFilter filter) {
+std::unique_ptr<OperationPass<FuncOp>> mlir::createLinalgStrategyPromotePass(
+ StringRef opName, const LinalgPromotionOptions &opt,
+ const LinalgTransformationFilter &filter) {
return std::make_unique<LinalgStrategyPromotePass>(opName, opt, filter);
}
/// Create a LinalgStrategyGeneralizePass.
-std::unique_ptr<OperationPass<FuncOp>>
-mlir::createLinalgStrategyGeneralizePass(StringRef opName,
- LinalgTransformationFilter filter) {
+std::unique_ptr<OperationPass<FuncOp>> mlir::createLinalgStrategyGeneralizePass(
+ StringRef opName, const LinalgTransformationFilter &filter) {
return std::make_unique<LinalgStrategyGeneralizePass>(opName, filter);
}
/// Create a LinalgStrategyDecomposePass.
// TODO: if/when we need finer control add an `opName` parameter.
-std::unique_ptr<OperationPass<FuncOp>>
-mlir::createLinalgStrategyDecomposePass(LinalgTransformationFilter filter) {
+std::unique_ptr<OperationPass<FuncOp>> mlir::createLinalgStrategyDecomposePass(
+ const LinalgTransformationFilter &filter) {
return std::make_unique<LinalgStrategyDecomposePass>(filter);
}
/// Create a LinalgStrategyInterchangePass.
std::unique_ptr<OperationPass<FuncOp>>
-mlir::createLinalgStrategyInterchangePass(ArrayRef<int64_t> iteratorInterchange,
- LinalgTransformationFilter filter) {
+mlir::createLinalgStrategyInterchangePass(
+ ArrayRef<int64_t> iteratorInterchange,
+ const LinalgTransformationFilter &filter) {
return std::make_unique<LinalgStrategyInterchangePass>(iteratorInterchange,
filter);
}
@@ -500,7 +503,7 @@ mlir::createLinalgStrategyInterchangePass(ArrayRef<int64_t> iteratorInterchange,
/// Create a LinalgStrategyVectorizePass.
std::unique_ptr<OperationPass<FuncOp>> mlir::createLinalgStrategyVectorizePass(
StringRef opName, LinalgVectorizationOptions opt,
- LinalgTransformationFilter filter, bool padVectorize) {
+ const LinalgTransformationFilter &filter, bool padVectorize) {
return std::make_unique<LinalgStrategyVectorizePass>(opName, opt, filter,
padVectorize);
}
@@ -508,14 +511,14 @@ std::unique_ptr<OperationPass<FuncOp>> mlir::createLinalgStrategyVectorizePass(
/// Create a LinalgStrategyEnablePass.
std::unique_ptr<OperationPass<FuncOp>>
mlir::createLinalgStrategyEnablePass(LinalgEnablingOptions opt,
- LinalgTransformationFilter filter) {
+ const LinalgTransformationFilter &filter) {
return std::make_unique<LinalgStrategyEnablePass>(opt, filter);
}
/// Create a LinalgStrategyLowerVectorsPass.
std::unique_ptr<OperationPass<FuncOp>>
-mlir::createLinalgStrategyLowerVectorsPass(LinalgVectorLoweringOptions opt,
- LinalgTransformationFilter filter) {
+mlir::createLinalgStrategyLowerVectorsPass(
+ LinalgVectorLoweringOptions opt, const LinalgTransformationFilter &filter) {
return std::make_unique<LinalgStrategyLowerVectorsPass>(opt, filter);
}
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
index 73f766f578ac..7fa2aed8dfd8 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
@@ -212,7 +212,7 @@ LinalgOpInstancePromotionOptions::LinalgOpInstancePromotionOptions(
// by a partial `copy` op.
FailureOr<PromotionInfo> mlir::linalg::promoteSubviewAsNewBuffer(
OpBuilder &b, Location loc, memref::SubViewOp subView,
- AllocBufferCallbackFn allocationFn, DataLayout &layout) {
+ const AllocBufferCallbackFn &allocationFn, DataLayout &layout) {
auto viewType = subView.getType();
auto rank = viewType.getRank();
SmallVector<Value, 4> fullSizes;
@@ -379,7 +379,7 @@ mlir::linalg::promoteSubviewsPrecondition(Operation *op,
FailureOr<LinalgOp>
mlir::linalg::promoteSubViews(OpBuilder &builder, LinalgOp linalgOp,
- LinalgPromotionOptions options) {
+ const LinalgPromotionOptions &options) {
LinalgOpInstancePromotionOptions linalgOptions(linalgOp, options);
auto layout = DataLayout::closest(linalgOp);
ImplicitLocOpBuilder b(linalgOp.getLoc(), builder);
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
index 21a76e1d84f1..b4d2860101fd 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
@@ -10,6 +10,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "PassDetail.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Passes.h"
@@ -392,7 +394,7 @@ static LogicalResult tilePadTensorOp(OpBuilder &builder, PadTensorOp op,
namespace {
struct PadTensorOpTilingPattern : public OpRewritePattern<PadTensorOp> {
PadTensorOpTilingPattern(MLIRContext *ctx, LinalgTilingOptions opt)
- : OpRewritePattern<PadTensorOp>(ctx), options(opt) {}
+ : OpRewritePattern<PadTensorOp>(ctx), options(std::move(opt)) {}
LogicalResult matchAndRewrite(PadTensorOp op,
PatternRewriter &rewriter) const override {
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 6ec237c56100..6d2af0c1cece 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -33,6 +33,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <type_traits>
+#include <utility>
#define DEBUG_TYPE "linalg-transforms"
@@ -54,7 +55,7 @@ mlir::linalg::LinalgTransformationFilter::LinalgTransformationFilter(
replacement(replacement), matchByDefault(false) {}
mlir::linalg::LinalgTransformationFilter::LinalgTransformationFilter(
- FilterFunction f, ArrayRef<StringAttr> matchDisjunction,
+ const FilterFunction &f, ArrayRef<StringAttr> matchDisjunction,
Optional<StringAttr> replacement)
: filters(),
matchDisjunction(matchDisjunction.begin(), matchDisjunction.end()),
@@ -287,14 +288,14 @@ linalg::rewriteAsPaddedOp(OpBuilder &b, LinalgOp opToPad,
mlir::linalg::LinalgBaseTilingPattern::LinalgBaseTilingPattern(
StringRef opName, MLIRContext *context, LinalgTilingOptions options,
LinalgTransformationFilter filter, PatternBenefit benefit)
- : RewritePattern(opName, benefit, context), filter(filter),
- options(options) {}
+ : RewritePattern(opName, benefit, context), filter(std::move(filter)),
+ options(std::move(options)) {}
mlir::linalg::LinalgBaseTilingPattern::LinalgBaseTilingPattern(
MLIRContext *context, LinalgTilingOptions options,
LinalgTransformationFilter filter, PatternBenefit benefit)
- : RewritePattern(MatchAnyOpTypeTag(), benefit, context), filter(filter),
- options(options) {}
+ : RewritePattern(MatchAnyOpTypeTag(), benefit, context),
+ filter(std::move(filter)), options(std::move(options)) {}
/// Try to peel a loop `op` and return the new result.
// TODO: Add support for scf.parallel and affine.for loops.
@@ -393,9 +394,10 @@ mlir::linalg::LinalgBaseTileAndFusePattern::LinalgBaseTileAndFusePattern(
LinalgTransformationFilter filter, LinalgTransformationFilter fusedOpMarker,
LinalgTransformationFilter originalOpMarker, PatternBenefit benefit)
: RewritePattern(opName, benefit, context, {}),
- dependenceGraph(dependenceGraph), tilingOptions(tilingOptions),
- fusionOptions(fusionOptions), filter(filter),
- fusedOpMarker(fusedOpMarker), originalOpMarker(originalOpMarker) {}
+ dependenceGraph(dependenceGraph), tilingOptions(std::move(tilingOptions)),
+ fusionOptions(std::move(fusionOptions)), filter(std::move(filter)),
+ fusedOpMarker(std::move(fusedOpMarker)),
+ originalOpMarker(std::move(originalOpMarker)) {}
LogicalResult mlir::linalg::LinalgBaseTileAndFusePattern::matchAndRewrite(
Operation *op, PatternRewriter &rewriter) const {
@@ -487,14 +489,14 @@ LogicalResult mlir::linalg::LinalgBaseTileAndFusePattern::matchAndRewrite(
mlir::linalg::LinalgPaddingPattern::LinalgPaddingPattern(
MLIRContext *context, LinalgPaddingOptions options,
LinalgTransformationFilter filter, PatternBenefit benefit)
- : RewritePattern(MatchAnyOpTypeTag(), benefit, context), filter(filter),
- options(options) {}
+ : RewritePattern(MatchAnyOpTypeTag(), benefit, context),
+ filter(std::move(filter)), options(std::move(options)) {}
mlir::linalg::LinalgPaddingPattern::LinalgPaddingPattern(
StringRef opName, MLIRContext *context, LinalgPaddingOptions options,
LinalgTransformationFilter filter, PatternBenefit benefit)
- : RewritePattern(opName, benefit, context, {}), filter(filter),
- options(options) {}
+ : RewritePattern(opName, benefit, context, {}), filter(std::move(filter)),
+ options(std::move(options)) {}
LogicalResult mlir::linalg::LinalgPaddingPattern::matchAndRewrite(
Operation *op, PatternRewriter &rewriter) const {
@@ -547,16 +549,16 @@ mlir::linalg::LinalgTileAndFuseTensorOpsPattern::
LinalgTilingAndFusionOptions options,
LinalgTransformationFilter filter,
PatternBenefit benefit)
- : RewritePattern(MatchAnyOpTypeTag(), benefit, context), filter(filter),
- options(options) {}
+ : RewritePattern(MatchAnyOpTypeTag(), benefit, context),
+ filter(std::move(filter)), options(std::move(options)) {}
mlir::linalg::LinalgTileAndFuseTensorOpsPattern::
LinalgTileAndFuseTensorOpsPattern(StringRef opName, MLIRContext *context,
LinalgTilingAndFusionOptions options,
LinalgTransformationFilter filter,
PatternBenefit benefit)
- : RewritePattern(opName, benefit, context), filter(filter),
- options(options) {}
+ : RewritePattern(opName, benefit, context), filter(std::move(filter)),
+ options(std::move(options)) {}
LogicalResult mlir::linalg::LinalgTileAndFuseTensorOpsPattern::matchAndRewrite(
Operation *op, PatternRewriter &rewriter) const {
@@ -614,7 +616,7 @@ LogicalResult mlir::linalg::LinalgTileAndFuseTensorOpsPattern::matchAndRewrite(
mlir::linalg::GenericOpInterchangePattern::GenericOpInterchangePattern(
MLIRContext *context, ArrayRef<unsigned> interchangeVector,
LinalgTransformationFilter filter, PatternBenefit benefit)
- : OpRewritePattern(context, benefit), filter(filter),
+ : OpRewritePattern(context, benefit), filter(std::move(filter)),
interchangeVector(interchangeVector.begin(), interchangeVector.end()) {}
LogicalResult mlir::linalg::GenericOpInterchangePattern::matchAndRewrite(
@@ -638,12 +640,13 @@ LogicalResult mlir::linalg::GenericOpInterchangePattern::matchAndRewrite(
mlir::linalg::LinalgGeneralizationPattern::LinalgGeneralizationPattern(
MLIRContext *context, LinalgTransformationFilter filter,
PatternBenefit benefit)
- : RewritePattern(MatchAnyOpTypeTag(), benefit, context), filter(filter) {}
+ : RewritePattern(MatchAnyOpTypeTag(), benefit, context),
+ filter(std::move(filter)) {}
mlir::linalg::LinalgGeneralizationPattern::LinalgGeneralizationPattern(
StringRef opName, MLIRContext *context, LinalgTransformationFilter filter,
PatternBenefit benefit)
- : RewritePattern(opName, benefit, context, {}), filter(filter) {}
+ : RewritePattern(opName, benefit, context, {}), filter(std::move(filter)) {}
LogicalResult mlir::linalg::LinalgGeneralizationPattern::matchAndRewrite(
Operation *op, PatternRewriter &rewriter) const {
@@ -661,14 +664,14 @@ LogicalResult mlir::linalg::LinalgGeneralizationPattern::matchAndRewrite(
mlir::linalg::LinalgBasePromotionPattern::LinalgBasePromotionPattern(
MLIRContext *context, LinalgTransformationFilter filter,
LinalgPromotionOptions options, PatternBenefit benefit)
- : RewritePattern(MatchAnyOpTypeTag(), benefit, context), filter(filter),
- options(options) {}
+ : RewritePattern(MatchAnyOpTypeTag(), benefit, context),
+ filter(std::move(filter)), options(std::move(options)) {}
mlir::linalg::LinalgBasePromotionPattern::LinalgBasePromotionPattern(
StringRef opName, MLIRContext *context, LinalgPromotionOptions options,
LinalgTransformationFilter filter, PatternBenefit benefit)
- : RewritePattern(opName, benefit, context, {}), filter(filter),
- options(options) {}
+ : RewritePattern(opName, benefit, context, {}), filter(std::move(filter)),
+ options(std::move(options)) {}
LogicalResult mlir::linalg::LinalgBasePromotionPattern::matchAndRewrite(
Operation *op, PatternRewriter &rewriter) const {
@@ -695,12 +698,13 @@ LogicalResult mlir::linalg::LinalgBasePromotionPattern::matchAndRewrite(
mlir::linalg::LinalgBaseVectorizationPattern::LinalgBaseVectorizationPattern(
MLIRContext *context, LinalgTransformationFilter filter,
PatternBenefit benefit)
- : RewritePattern(MatchAnyOpTypeTag(), benefit, context), filter(filter) {}
+ : RewritePattern(MatchAnyOpTypeTag(), benefit, context),
+ filter(std::move(filter)) {}
mlir::linalg::LinalgBaseVectorizationPattern::LinalgBaseVectorizationPattern(
StringRef opName, MLIRContext *context, LinalgTransformationFilter filter,
PatternBenefit benefit)
- : RewritePattern(opName, benefit, context, {}), filter(filter) {}
+ : RewritePattern(opName, benefit, context, {}), filter(std::move(filter)) {}
LogicalResult mlir::linalg::LinalgBaseVectorizationPattern::matchAndRewrite(
Operation *op, PatternRewriter &rewriter) const {
@@ -942,7 +946,8 @@ struct DownscaleSizeOneWindowed2DConvolution final
MLIRContext *context,
LinalgTransformationFilter filter = LinalgTransformationFilter(),
PatternBenefit benefit = 1)
- : OpRewritePattern<Conv2DNhwcHwcfOp>(context, benefit), filter(filter) {}
+ : OpRewritePattern<Conv2DNhwcHwcfOp>(context, benefit),
+ filter(std::move(filter)) {}
LogicalResult matchAndRewrite(linalg::Conv2DNhwcHwcfOp convOp,
PatternRewriter &rewriter) const override {
@@ -1028,7 +1033,7 @@ struct DownscaleDepthwiseConv2DNhwcHwcOp final
LinalgTransformationFilter filter = LinalgTransformationFilter(),
PatternBenefit benefit = 1)
: OpRewritePattern<DepthwiseConv2DNhwcHwcOp>(context, benefit),
- filter(filter) {}
+ filter(std::move(filter)) {}
LogicalResult matchAndRewrite(DepthwiseConv2DNhwcHwcOp convOp,
PatternRewriter &rewriter) const override {
@@ -1108,7 +1113,7 @@ struct DownscaleDepthwiseConv2DNhwcHwcOp final
} // namespace
void linalg::populateDecomposeConvolutionPatterns(
- RewritePatternSet &patterns, LinalgTransformationFilter filter,
+ RewritePatternSet &patterns, const LinalgTransformationFilter &filter,
PatternBenefit benefit) {
patterns.add<DownscaleSizeOneWindowed2DConvolution,
DownscaleDepthwiseConv2DNhwcHwcOp>(patterns.getContext(), filter,
diff --git a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
index 2dbee7eaac6f..9931e89647bc 100644
--- a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
+++ b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
@@ -83,7 +83,7 @@ static Value broadcast(ImplicitLocOpBuilder &builder, Value value,
static Value
handleMultidimensionalVectors(ImplicitLocOpBuilder &builder,
ValueRange operands, int64_t vectorWidth,
- std::function<Value(ValueRange)> compute) {
+ llvm::function_ref<Value(ValueRange)> compute) {
assert(!operands.empty() && "operands must be not empty");
assert(vectorWidth > 0 && "vector width must be larger than 0");
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
index d1bd271d389b..aaa0fb33ae91 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
@@ -10,6 +10,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/CommonFolders.h"
@@ -161,8 +163,8 @@ OpFoldResult spirv::IAddOp::fold(ArrayRef<Attribute> operands) {
// The resulting value will equal the low-order N bits of the correct result
// R, where N is the component width and R is computed with enough precision
// to avoid overflow and underflow.
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a + b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](APInt a, const APInt &b) { return std::move(a) + b; });
}
//===----------------------------------------------------------------------===//
@@ -183,8 +185,8 @@ OpFoldResult spirv::IMulOp::fold(ArrayRef<Attribute> operands) {
// The resulting value will equal the low-order N bits of the correct result
// R, where N is the component width and R is computed with enough precision
// to avoid overflow and underflow.
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a * b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](const APInt &a, const APInt &b) { return a * b; });
}
//===----------------------------------------------------------------------===//
@@ -201,8 +203,8 @@ OpFoldResult spirv::ISubOp::fold(ArrayRef<Attribute> operands) {
// The resulting value will equal the low-order N bits of the correct result
// R, where N is the component width and R is computed with enough precision
// to avoid overflow and underflow.
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a - b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](APInt a, const APInt &b) { return std::move(a) - b; });
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp
index db86e2288673..4a415b456826 100644
--- a/mlir/lib/Dialect/Shape/IR/Shape.cpp
+++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/Dialect/Shape/IR/Shape.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
@@ -444,8 +446,8 @@ OpFoldResult mlir::shape::AddOp::fold(ArrayRef<Attribute> operands) {
if (matchPattern(getRhs(), m_Zero()))
return getLhs();
- return constFoldBinaryOp<IntegerAttr>(operands,
- [](APInt a, APInt b) { return a + b; });
+ return constFoldBinaryOp<IntegerAttr>(
+ operands, [](APInt a, const APInt &b) { return std::move(a) + b; });
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index a74b46c034c4..de45339f8955 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -1046,7 +1046,7 @@ static void printSwitchOpCases(
OpAsmPrinter &p, SwitchOp op, Type flagType, Block *defaultDestination,
OperandRange defaultOperands, TypeRange defaultOperandTypes,
DenseIntElementsAttr caseValues, SuccessorRange caseDestinations,
- OperandRangeRange caseOperands, TypeRangeRange caseOperandTypes) {
+ OperandRangeRange caseOperands, const TypeRangeRange &caseOperandTypes) {
p << " default: ";
p.printSuccessorAndUseList(defaultDestination, defaultOperands);
@@ -1172,7 +1172,7 @@ dropSwitchCasesThatMatchDefault(SwitchOp op, PatternRewriter &rewriter) {
/// ]
/// -> br ^bb2
static void foldSwitch(SwitchOp op, PatternRewriter &rewriter,
- APInt caseValue) {
+ const APInt &caseValue) {
auto caseValues = op.getCaseValues();
for (const auto &it : llvm::enumerate(caseValues->getValues<APInt>())) {
if (it.value() == caseValue) {
diff --git a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
index ddba1d3c4432..b5136273d635 100644
--- a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
+++ b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
@@ -215,7 +215,7 @@ ArrayAttr mlir::getReassociationIndicesAttribute(
OpBuilder &b, ArrayRef<ReassociationIndices> reassociation) {
SmallVector<Attribute, 4> reassociationAttr =
llvm::to_vector<4>(llvm::map_range(
- reassociation, [&](ReassociationIndices indices) -> Attribute {
+ reassociation, [&](const ReassociationIndices &indices) -> Attribute {
return b.getI64ArrayAttr(indices).cast<Attribute>();
}));
return b.getArrayAttr(reassociationAttr);
diff --git a/mlir/lib/Dialect/Vector/VectorMultiDimReductionTransforms.cpp b/mlir/lib/Dialect/Vector/VectorMultiDimReductionTransforms.cpp
index 965b29257ee6..f012bf486bdf 100644
--- a/mlir/lib/Dialect/Vector/VectorMultiDimReductionTransforms.cpp
+++ b/mlir/lib/Dialect/Vector/VectorMultiDimReductionTransforms.cpp
@@ -46,7 +46,7 @@ class InnerOuterDimReductionConversion
auto reductionDimsRange =
multiReductionOp.reduction_dims().getAsValueRange<IntegerAttr>();
auto reductionDims = llvm::to_vector<4>(llvm::map_range(
- reductionDimsRange, [](APInt a) { return a.getZExtValue(); }));
+ reductionDimsRange, [](const APInt &a) { return a.getZExtValue(); }));
llvm::SmallDenseSet<int64_t> reductionDimsSet(reductionDims.begin(),
reductionDims.end());
int64_t reductionSize = reductionDims.size();
diff --git a/mlir/lib/IR/AffineExpr.cpp b/mlir/lib/IR/AffineExpr.cpp
index f0f54ce7f8a0..47dcff627a33 100644
--- a/mlir/lib/IR/AffineExpr.cpp
+++ b/mlir/lib/IR/AffineExpr.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/IR/AffineExpr.h"
#include "AffineExprDetail.h"
#include "mlir/IR/AffineExprVisitor.h"
@@ -28,7 +30,7 @@ void AffineExpr::walk(std::function<void(AffineExpr)> callback) const {
std::function<void(AffineExpr)> callback;
AffineExprWalker(std::function<void(AffineExpr)> callback)
- : callback(callback) {}
+ : callback(std::move(callback)) {}
void visitAffineBinaryOpExpr(AffineBinaryOpExpr expr) { callback(expr); }
void visitConstantExpr(AffineConstantExpr expr) { callback(expr); }
@@ -36,7 +38,7 @@ void AffineExpr::walk(std::function<void(AffineExpr)> callback) const {
void visitSymbolExpr(AffineSymbolExpr expr) { callback(expr); }
};
- AffineExprWalker(callback).walkPostOrder(*this);
+ AffineExprWalker(std::move(callback)).walkPostOrder(*this);
}
// Dispatch affine expression construction based on kind.
diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp
index b15d49fd4105..a60120637011 100644
--- a/mlir/lib/IR/AffineMap.cpp
+++ b/mlir/lib/IR/AffineMap.cpp
@@ -384,7 +384,7 @@ AffineMap::partialConstantFold(ArrayRef<Attribute> operandConstants,
/// Walk all of the AffineExpr's in this mapping. Each node in an expression
/// tree is visited in postorder.
-void AffineMap::walkExprs(std::function<void(AffineExpr)> callback) const {
+void AffineMap::walkExprs(llvm::function_ref<void(AffineExpr)> callback) const {
for (auto expr : getResults())
expr.walk(callback);
}
diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp
index 2e2a1465ac0f..d29feacb9786 100644
--- a/mlir/lib/IR/Diagnostics.cpp
+++ b/mlir/lib/IR/Diagnostics.cpp
@@ -875,7 +875,7 @@ struct ParallelDiagnosticHandlerImpl : public llvm::PrettyStackTraceEntry {
}
/// Utility method to emit any held diagnostics.
- void emitDiagnostics(std::function<void(Diagnostic)> emitFn) const {
+ void emitDiagnostics(llvm::function_ref<void(Diagnostic)> emitFn) const {
// Stable sort all of the diagnostics that were emitted. This creates a
// deterministic ordering for the diagnostics based upon which order id they
// were emitted for.
diff --git a/mlir/lib/IR/Dialect.cpp b/mlir/lib/IR/Dialect.cpp
index 6d1d48edbefd..b14876a16576 100644
--- a/mlir/lib/IR/Dialect.cpp
+++ b/mlir/lib/IR/Dialect.cpp
@@ -32,7 +32,7 @@ DialectRegistry::DialectRegistry() { insert<BuiltinDialect>(); }
void DialectRegistry::addDialectInterface(
StringRef dialectName, TypeID interfaceTypeID,
- DialectInterfaceAllocatorFunction allocator) {
+ const DialectInterfaceAllocatorFunction &allocator) {
assert(allocator && "unexpected null interface allocation function");
auto it = registry.find(dialectName.str());
assert(it != registry.end() &&
@@ -57,7 +57,7 @@ void DialectRegistry::addDialectInterface(
void DialectRegistry::addObjectInterface(
StringRef dialectName, TypeID objectID, TypeID interfaceTypeID,
- ObjectInterfaceAllocatorFunction allocator) {
+ const ObjectInterfaceAllocatorFunction &allocator) {
assert(allocator && "unexpected null interface allocation function");
auto it = registry.find(dialectName.str());
@@ -88,7 +88,7 @@ DialectRegistry::getDialectAllocator(StringRef name) const {
}
void DialectRegistry::insert(TypeID typeID, StringRef name,
- DialectAllocatorFunction ctor) {
+ const DialectAllocatorFunction &ctor) {
auto inserted = registry.insert(
std::make_pair(std::string(name), std::make_pair(typeID, ctor)));
if (!inserted.second && inserted.first->second.first != typeID) {
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 888cab9eb568..e06492292c1d 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -995,7 +995,7 @@ LogicalResult OpTrait::impl::verifyValueSizeAttr(Operation *op,
size_t totalCount = std::accumulate(
sizeAttr.begin(), sizeAttr.end(), 0,
- [](unsigned all, APInt one) { return all + one.getZExtValue(); });
+ [](unsigned all, const APInt &one) { return all + one.getZExtValue(); });
if (totalCount != expectedCount)
return op->emitOpError()
diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp
index e3d22f2b1cb0..30d5a8e1a779 100644
--- a/mlir/lib/Pass/IRPrinting.cpp
+++ b/mlir/lib/Pass/IRPrinting.cpp
@@ -223,9 +223,9 @@ struct BasicIRPrinterConfig : public PassManager::IRPrinterConfig {
raw_ostream &out)
: IRPrinterConfig(printModuleScope, printAfterOnlyOnChange,
printAfterOnlyOnFailure, opPrintingFlags),
- shouldPrintBeforePass(shouldPrintBeforePass),
- shouldPrintAfterPass(shouldPrintAfterPass), out(out) {
- assert((shouldPrintBeforePass || shouldPrintAfterPass) &&
+ shouldPrintBeforePass(std::move(shouldPrintBeforePass)),
+ shouldPrintAfterPass(std::move(shouldPrintAfterPass)), out(out) {
+ assert((this->shouldPrintBeforePass || this->shouldPrintAfterPass) &&
"expected at least one valid filter function");
}
diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp
index e86a315dc355..933d77bbef12 100644
--- a/mlir/lib/Pass/PassRegistry.cpp
+++ b/mlir/lib/Pass/PassRegistry.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/Pass/PassRegistry.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
@@ -88,7 +90,8 @@ size_t PassRegistryEntry::getOptionWidth() const {
void mlir::registerPassPipeline(
StringRef arg, StringRef description, const PassRegistryFunction &function,
std::function<void(function_ref<void(const PassOptions &)>)> optHandler) {
- PassPipelineInfo pipelineInfo(arg, description, function, optHandler);
+ PassPipelineInfo pipelineInfo(arg, description, function,
+ std::move(optHandler));
bool inserted = passPipelineRegistry->try_emplace(arg, pipelineInfo).second;
assert(inserted && "Pass pipeline registered multiple times");
(void)inserted;
diff --git a/mlir/lib/Reducer/ReductionNode.cpp b/mlir/lib/Reducer/ReductionNode.cpp
index 05d4c594100b..2aa551ed8338 100644
--- a/mlir/lib/Reducer/ReductionNode.cpp
+++ b/mlir/lib/Reducer/ReductionNode.cpp
@@ -24,7 +24,7 @@
using namespace mlir;
ReductionNode::ReductionNode(
- ReductionNode *parentNode, std::vector<Range> ranges,
+ ReductionNode *parentNode, const std::vector<Range> &ranges,
llvm::SpecificBumpPtrAllocator<ReductionNode> &allocator)
/// Root node will have the parent pointer point to themselves.
: parent(parentNode == nullptr ? this : parentNode),
diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp
index 92cd68162093..d8c5e08bfcef 100644
--- a/mlir/lib/TableGen/Pattern.cpp
+++ b/mlir/lib/TableGen/Pattern.cpp
@@ -11,6 +11,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/TableGen/Pattern.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
@@ -217,7 +219,7 @@ StringRef SymbolInfoMap::getValuePackName(StringRef symbol, int *index) {
SymbolInfoMap::SymbolInfo::SymbolInfo(const Operator *op, SymbolInfo::Kind kind,
Optional<DagAndConstant> dagAndConstant)
- : op(op), kind(kind), dagAndConstant(dagAndConstant) {}
+ : op(op), kind(kind), dagAndConstant(std::move(dagAndConstant)) {}
int SymbolInfoMap::SymbolInfo::getStaticValueCount() const {
switch (kind) {
@@ -502,7 +504,8 @@ SymbolInfoMap::findBoundSymbol(StringRef key, DagNode node, const Operator &op,
}
SymbolInfoMap::const_iterator
-SymbolInfoMap::findBoundSymbol(StringRef key, SymbolInfo symbolInfo) const {
+SymbolInfoMap::findBoundSymbol(StringRef key,
+ const SymbolInfo &symbolInfo) const {
std::string name = getValuePackName(key).str();
auto range = symbolInfoMap.equal_range(name);
diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp
index 7238a866a446..46de82079989 100644
--- a/mlir/lib/TableGen/Predicate.cpp
+++ b/mlir/lib/TableGen/Predicate.cpp
@@ -286,7 +286,8 @@ propagateGroundTruth(PredNode *node,
// Combine a list of predicate expressions using a binary combiner. If a list
// is empty, return "init".
static std::string combineBinary(ArrayRef<std::string> children,
- std::string combiner, std::string init) {
+ const std::string &combiner,
+ std::string init) {
if (children.empty())
return init;
diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
index bf2a2e846146..473c9ad7f171 100644
--- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp
+++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/Dialect/EmitC/IR/EmitC.h"
#include "mlir/Dialect/SCF/SCF.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
@@ -689,7 +691,7 @@ bool CppEmitter::hasBlockLabel(Block &block) {
}
LogicalResult CppEmitter::emitAttribute(Location loc, Attribute attr) {
- auto printInt = [&](APInt val, bool isUnsigned) {
+ auto printInt = [&](const APInt &val, bool isUnsigned) {
if (val.getBitWidth() == 1) {
if (val.getBoolValue())
os << "true";
@@ -702,7 +704,7 @@ LogicalResult CppEmitter::emitAttribute(Location loc, Attribute attr) {
}
};
- auto printFloat = [&](APFloat val) {
+ auto printFloat = [&](const APFloat &val) {
if (val.isFinite()) {
SmallString<128> strValue;
// Use default values of toString except don't truncate zeros.
@@ -734,7 +736,8 @@ LogicalResult CppEmitter::emitAttribute(Location loc, Attribute attr) {
}
if (auto dense = attr.dyn_cast<DenseFPElementsAttr>()) {
os << '{';
- interleaveComma(dense, os, [&](APFloat val) { printFloat(val); });
+ interleaveComma(dense, os,
+ [&](APFloat val) { printFloat(std::move(val)); });
os << '}';
return success();
}
@@ -757,7 +760,7 @@ LogicalResult CppEmitter::emitAttribute(Location loc, Attribute attr) {
.dyn_cast<IntegerType>()) {
os << '{';
interleaveComma(dense, os, [&](APInt val) {
- printInt(val, shouldMapToUnsigned(iType.getSignedness()));
+ printInt(std::move(val), shouldMapToUnsigned(iType.getSignedness()));
});
os << '}';
return success();
@@ -767,7 +770,8 @@ LogicalResult CppEmitter::emitAttribute(Location loc, Attribute attr) {
.getElementType()
.dyn_cast<IndexType>()) {
os << '{';
- interleaveComma(dense, os, [&](APInt val) { printInt(val, false); });
+ interleaveComma(dense, os,
+ [&](APInt val) { printInt(std::move(val), false); });
os << '}';
return success();
}
diff --git a/mlir/lib/Tools/mlir-lsp-server/lsp/Transport.cpp b/mlir/lib/Tools/mlir-lsp-server/lsp/Transport.cpp
index 35d6734b1935..9a64938281dd 100644
--- a/mlir/lib/Tools/mlir-lsp-server/lsp/Transport.cpp
+++ b/mlir/lib/Tools/mlir-lsp-server/lsp/Transport.cpp
@@ -13,6 +13,7 @@
#include "llvm/Support/Errno.h"
#include "llvm/Support/Error.h"
#include <system_error>
+#include <utility>
using namespace mlir;
using namespace mlir::lsp;
@@ -87,7 +88,7 @@ bool MessageHandler::onNotify(llvm::StringRef method, llvm::json::Value value) {
} else {
auto it = notificationHandlers.find(method);
if (it != notificationHandlers.end())
- it->second(value);
+ it->second(std::move(value));
}
return true;
}
@@ -100,7 +101,7 @@ bool MessageHandler::onCall(llvm::StringRef method, llvm::json::Value params,
auto it = methodHandlers.find(method);
if (it != methodHandlers.end()) {
- it->second(params, std::move(reply));
+ it->second(std::move(params), std::move(reply));
} else {
reply(llvm::make_error<LSPError>("method not found: " + method.str(),
ErrorCode::MethodNotFound));
diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp
index f080b4d112ba..c0befb76eed0 100644
--- a/mlir/lib/Transforms/Inliner.cpp
+++ b/mlir/lib/Transforms/Inliner.cpp
@@ -563,7 +563,7 @@ class InlinerPass : public InlinerBase<InlinerPass> {
InlinerPass::InlinerPass() : InlinerPass(defaultInlinerOptPipeline) {}
InlinerPass::InlinerPass(std::function<void(OpPassManager &)> defaultPipeline)
- : defaultPipeline(defaultPipeline) {
+ : defaultPipeline(std::move(defaultPipeline)) {
opPipelines.push_back({});
// Initialize the pass options with the provided arguments.
diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp
index 365779494e48..04a1e0fd4ef0 100644
--- a/mlir/lib/Transforms/ViewOpGraph.cpp
+++ b/mlir/lib/Transforms/ViewOpGraph.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/Transforms/ViewOpGraph.h"
#include "PassDetail.h"
#include "mlir/IR/Block.h"
@@ -43,7 +45,9 @@ static std::string escapeString(std::string str) {
}
/// Put quotation marks around a given string.
-static std::string quoteString(std::string str) { return "\"" + str + "\""; }
+static std::string quoteString(const std::string &str) {
+ return "\"" + str + "\"";
+}
using AttributeMap = llvm::StringMap<std::string>;
@@ -104,7 +108,8 @@ class PrintOpPass : public ViewOpGraphBase<PrintOpPass> {
os.indent();
// Emit invisible anchor node from/to which arrows can be drawn.
Node anchorNode = emitNodeStmt(" ", kShapeNone);
- os << attrStmt("label", quoteString(escapeString(label))) << ";\n";
+ os << attrStmt("label", quoteString(escapeString(std::move(label))))
+ << ";\n";
builder();
os.unindent();
os << "}\n";
@@ -167,7 +172,7 @@ class PrintOpPass : public ViewOpGraphBase<PrintOpPass> {
// clipped at the boundary, but labels are not. This can lead to labels
// floating around without any edge next to them.
if (!n1.clusterId && !n2.clusterId)
- attrs["label"] = quoteString(escapeString(label));
+ attrs["label"] = quoteString(escapeString(std::move(label)));
// Use `ltail` and `lhead` to draw edges between clusters.
if (n1.clusterId)
attrs["ltail"] = "cluster_" + std::to_string(*n1.clusterId);
@@ -195,7 +200,7 @@ class PrintOpPass : public ViewOpGraphBase<PrintOpPass> {
Node emitNodeStmt(std::string label, StringRef shape = kShapeNode) {
int nodeId = ++counter;
AttributeMap attrs;
- attrs["label"] = quoteString(escapeString(label));
+ attrs["label"] = quoteString(escapeString(std::move(label)));
attrs["shape"] = shape.str();
os << llvm::format("v%i ", nodeId);
emitAttrList(os, attrs);
diff --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp
index 0dc0e6c5ae66..43349a82c263 100644
--- a/mlir/lib/Translation/Translation.cpp
+++ b/mlir/lib/Translation/Translation.cpp
@@ -94,7 +94,7 @@ TranslateToMLIRRegistration::TranslateToMLIRRegistration(
TranslateFromMLIRRegistration::TranslateFromMLIRRegistration(
StringRef name, const TranslateFromMLIRFunction &function,
- std::function<void(DialectRegistry &)> dialectRegistration) {
+ const std::function<void(DialectRegistry &)> &dialectRegistration) {
registerTranslation(name, [function, dialectRegistration](
llvm::SourceMgr &sourceMgr, raw_ostream &output,
MLIRContext *context) {
diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp
index d798042bfac8..0e18725b5eb2 100644
--- a/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp
+++ b/mlir/test/lib/Dialect/Linalg/TestLinalgCodegenStrategy.cpp
@@ -10,6 +10,8 @@
//
//===----------------------------------------------------------------------===//
+#include <utility>
+
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/GPU/GPUDialect.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
@@ -175,19 +177,20 @@ void TestLinalgCodegenStrategy::runStrategy(
CodegenStrategy strategy;
strategy
.tileAndFuseIf(fuse && !tileSizes.empty(), anchorOpName,
- tilingAndFusionOptions)
- .tileIf(!fuse && !tileSizes.empty(), anchorOpName, tilingOptions)
+ std::move(tilingAndFusionOptions))
+ .tileIf(!fuse && !tileSizes.empty(), anchorOpName,
+ std::move(tilingOptions))
.promoteIf(!fuse && promote, anchorOpName,
LinalgPromotionOptions()
.setAlignment(16)
.setUseFullTileBuffersByDefault(promoteFullTile))
.tileIf(!fuse && !registerTileSizes.empty(), anchorOpName,
- registerTilingOptions)
+ std::move(registerTilingOptions))
.promoteIf(!fuse && registerPromote, anchorOpName,
LinalgPromotionOptions()
.setAlignment(16)
.setUseFullTileBuffersByDefault(registerPromoteFullTile))
- .padIf(pad, "", paddingOptions)
+ .padIf(pad, "", std::move(paddingOptions))
.decomposeIf(decompose)
.generalizeIf(generalize, "")
.interchangeIf(!iteratorInterchange.empty(), iteratorInterchange)
diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp
index 64713b02c7b6..d4119f26c819 100644
--- a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp
+++ b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp
@@ -567,7 +567,7 @@ static void applyExtractSliceOfPadTensorSwapPattern(FuncOp funcOp) {
(void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
}
-static void applyTilePattern(FuncOp funcOp, std::string loopType,
+static void applyTilePattern(FuncOp funcOp, const std::string &loopType,
ArrayRef<int64_t> tileSizes,
ArrayRef<int64_t> peeledLoops,
bool scalarizeDynamicDims) {
diff --git a/mlir/tools/mlir-tblgen/DialectGen.cpp b/mlir/tools/mlir-tblgen/DialectGen.cpp
index 73b41ebde7ec..7da5a3c84681 100644
--- a/mlir/tools/mlir-tblgen/DialectGen.cpp
+++ b/mlir/tools/mlir-tblgen/DialectGen.cpp
@@ -185,10 +185,11 @@ static const char *const operationInterfaceFallbackDecl = R"(
)";
/// Generate the declaration for the given dialect class.
-static void emitDialectDecl(Dialect &dialect,
- iterator_range<DialectFilterIterator> dialectAttrs,
- iterator_range<DialectFilterIterator> dialectTypes,
- raw_ostream &os) {
+static void
+emitDialectDecl(Dialect &dialect,
+ const iterator_range<DialectFilterIterator> &dialectAttrs,
+ const iterator_range<DialectFilterIterator> &dialectTypes,
+ raw_ostream &os) {
/// Build the list of dependent dialects
std::string dependentDialectRegistrations;
{
diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index 3025df140ea9..525d96d06ac5 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -88,7 +88,7 @@ static void emitAssemblyFormat(StringRef opName, StringRef format,
os << "```\n\n";
}
-static void emitOpTraitsDoc(Operator op, raw_ostream &os) {
+static void emitOpTraitsDoc(const Operator &op, raw_ostream &os) {
// TODO: We should link to the trait/documentation of it. That also means we
// should add descriptions to traits that can be queried.
// Collect using set to sort effects, interfaces & traits.
diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index adbd8407af99..02d0e81b6860 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -2217,7 +2217,7 @@ class FormatParser {
/// attribute.
void handleTypesMatchConstraint(
llvm::StringMap<TypeResolutionInstance> &variableTyResolver,
- llvm::Record def);
+ const llvm::Record &def);
/// Returns an argument or attribute with the given name that has been seen
/// within the format.
@@ -2621,7 +2621,7 @@ void FormatParser::handleSameTypesConstraint(
void FormatParser::handleTypesMatchConstraint(
llvm::StringMap<TypeResolutionInstance> &variableTyResolver,
- llvm::Record def) {
+ const llvm::Record &def) {
StringRef lhsName = def.getValueAsString("lhs");
StringRef rhsName = def.getValueAsString("rhs");
StringRef transformer = def.getValueAsString("transformer");
diff --git a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
index 366a236c72c7..4ec33a901b5a 100644
--- a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
@@ -154,7 +154,7 @@ struct TypeInterfaceGenerator : public InterfaceGenerator {
// GEN: Interface definitions
//===----------------------------------------------------------------------===//
-static void emitInterfaceDef(Interface interface, StringRef valueType,
+static void emitInterfaceDef(const Interface &interface, StringRef valueType,
raw_ostream &os) {
StringRef interfaceName = interface.getName();
StringRef cppNamespace = interface.getCppNamespace();
diff --git a/mlir/tools/mlir-tblgen/mlir-tblgen.cpp b/mlir/tools/mlir-tblgen/mlir-tblgen.cpp
index 0f14b190d891..6a2bbcd0baa4 100644
--- a/mlir/tools/mlir-tblgen/mlir-tblgen.cpp
+++ b/mlir/tools/mlir-tblgen/mlir-tblgen.cpp
@@ -29,7 +29,7 @@ using namespace mlir;
static llvm::ManagedStatic<std::vector<GenInfo>> generatorRegistry;
mlir::GenRegistration::GenRegistration(StringRef arg, StringRef description,
- GenFunction function) {
+ const GenFunction &function) {
generatorRegistry->emplace_back(arg, description, function);
}
diff --git a/mlir/unittests/Analysis/AffineStructuresParserTest.cpp b/mlir/unittests/Analysis/AffineStructuresParserTest.cpp
index 14be5a3faf3e..d219326bce47 100644
--- a/mlir/unittests/Analysis/AffineStructuresParserTest.cpp
+++ b/mlir/unittests/Analysis/AffineStructuresParserTest.cpp
@@ -73,7 +73,7 @@ TEST(ParseFACTest, InvalidInputTest) {
/// Parses and compares the `str` to the `ex`. The equality check is performed
/// by using PresburgerSet::isEqual
-static bool parseAndCompare(StringRef str, FlatAffineConstraints ex,
+static bool parseAndCompare(StringRef str, const FlatAffineConstraints &ex,
MLIRContext *context) {
FailureOr<FlatAffineConstraints> fac = parseIntegerSetToFAC(str, context);
diff --git a/mlir/unittests/Analysis/Presburger/SimplexTest.cpp b/mlir/unittests/Analysis/Presburger/SimplexTest.cpp
index fd5750dd3756..40fa9e3d60be 100644
--- a/mlir/unittests/Analysis/Presburger/SimplexTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/SimplexTest.cpp
@@ -93,8 +93,8 @@ TEST(SimplexTest, addInequality_rollback) {
}
Simplex simplexFromConstraints(unsigned nDim,
- SmallVector<SmallVector<int64_t, 8>, 8> ineqs,
- SmallVector<SmallVector<int64_t, 8>, 8> eqs) {
+ ArrayRef<SmallVector<int64_t, 8>> ineqs,
+ ArrayRef<SmallVector<int64_t, 8>> eqs) {
Simplex simplex(nDim);
for (const auto &ineq : ineqs)
simplex.addInequality(ineq);
diff --git a/mlir/unittests/Analysis/PresburgerSetTest.cpp b/mlir/unittests/Analysis/PresburgerSetTest.cpp
index c7c3c0db4f5f..0606db4d8957 100644
--- a/mlir/unittests/Analysis/PresburgerSetTest.cpp
+++ b/mlir/unittests/Analysis/PresburgerSetTest.cpp
@@ -48,7 +48,7 @@ static PresburgerSet parsePresburgerSetFromFACStrings(unsigned numDims,
/// Compute the union of s and t, and check that each of the given points
/// belongs to the union iff it belongs to at least one of s and t.
-static void testUnionAtPoints(PresburgerSet s, PresburgerSet t,
+static void testUnionAtPoints(const PresburgerSet &s, const PresburgerSet &t,
ArrayRef<SmallVector<int64_t, 4>> points) {
PresburgerSet unionSet = s.unionSet(t);
for (const SmallVector<int64_t, 4> &point : points) {
@@ -61,7 +61,8 @@ static void testUnionAtPoints(PresburgerSet s, PresburgerSet t,
/// Compute the intersection of s and t, and check that each of the given points
/// belongs to the intersection iff it belongs to both s and t.
-static void testIntersectAtPoints(PresburgerSet s, PresburgerSet t,
+static void testIntersectAtPoints(const PresburgerSet &s,
+ const PresburgerSet &t,
ArrayRef<SmallVector<int64_t, 4>> points) {
PresburgerSet intersection = s.intersect(t);
for (const SmallVector<int64_t, 4> &point : points) {
@@ -74,7 +75,7 @@ static void testIntersectAtPoints(PresburgerSet s, PresburgerSet t,
/// Compute the set
diff erence s \ t, and check that each of the given points
/// belongs to the
diff erence iff it belongs to s and does not belong to t.
-static void testSubtractAtPoints(PresburgerSet s, PresburgerSet t,
+static void testSubtractAtPoints(const PresburgerSet &s, const PresburgerSet &t,
ArrayRef<SmallVector<int64_t, 4>> points) {
PresburgerSet
diff = s.subtract(t);
for (const SmallVector<int64_t, 4> &point : points) {
@@ -90,7 +91,7 @@ static void testSubtractAtPoints(PresburgerSet s, PresburgerSet t,
/// Compute the complement of s, and check that each of the given points
/// belongs to the complement iff it does not belong to s.
-static void testComplementAtPoints(PresburgerSet s,
+static void testComplementAtPoints(const PresburgerSet &s,
ArrayRef<SmallVector<int64_t, 4>> points) {
PresburgerSet complement = s.complement();
complement.complement();
@@ -473,7 +474,7 @@ void expectEqual(const PresburgerSet &s, const PresburgerSet &t) {
EXPECT_TRUE(s.isEqual(t));
}
-void expectEmpty(PresburgerSet s) { EXPECT_TRUE(s.isIntegerEmpty()); }
+void expectEmpty(const PresburgerSet &s) { EXPECT_TRUE(s.isIntegerEmpty()); }
TEST(SetTest, divisions) {
MLIRContext context;
@@ -511,7 +512,7 @@ TEST(SetTest, divisions) {
/// Coalesce `set` and check that the `newSet` is equal to `set and that
/// `expectedNumFACs` matches the number of FACs in the coalesced set.
/// If one of the two
-void expectCoalesce(size_t expectedNumFACs, const PresburgerSet set) {
+void expectCoalesce(size_t expectedNumFACs, const PresburgerSet &set) {
PresburgerSet newSet = set.coalesce();
EXPECT_TRUE(set.isEqual(newSet));
EXPECT_TRUE(expectedNumFACs == newSet.getNumFACs());
diff --git a/mlir/unittests/Conversion/PDLToPDLInterp/RootOrderingTest.cpp b/mlir/unittests/Conversion/PDLToPDLInterp/RootOrderingTest.cpp
index 5d9b1af7847a..5f209fb6fdfe 100644
--- a/mlir/unittests/Conversion/PDLToPDLInterp/RootOrderingTest.cpp
+++ b/mlir/unittests/Conversion/PDLToPDLInterp/RootOrderingTest.cpp
@@ -46,7 +46,7 @@ class RootOrderingTest : public ::testing::Test {
/// Checks that optimal branching on graph has the given cost and
/// its preorder traversal results in the specified edges.
- void check(unsigned cost, OptimalBranching::EdgeList edges) {
+ void check(unsigned cost, const OptimalBranching::EdgeList &edges) {
OptimalBranching opt(graph, v[0]);
EXPECT_EQ(opt.solve(), cost);
EXPECT_EQ(opt.preOrderTraversal({v, v + edges.size()}), edges);
diff --git a/mlir/unittests/Dialect/SparseTensor/MergerTest.cpp b/mlir/unittests/Dialect/SparseTensor/MergerTest.cpp
index 9ec6c1b15b1a..fe69878c8283 100644
--- a/mlir/unittests/Dialect/SparseTensor/MergerTest.cpp
+++ b/mlir/unittests/Dialect/SparseTensor/MergerTest.cpp
@@ -22,7 +22,8 @@ struct Pattern {
/// Rather than using these, please use the readable helper constructor
/// functions below to make tests more readable.
Pattern(unsigned tensorNum) : kind(Kind::kTensor), tensorNum(tensorNum) {}
- Pattern(Kind kind, std::shared_ptr<Pattern> e0, std::shared_ptr<Pattern> e1)
+ Pattern(Kind kind, const std::shared_ptr<Pattern> &e0,
+ const std::shared_ptr<Pattern> &e1)
: kind(kind), e0(e0), e1(e1) {
assert(kind >= Kind::kMulF);
assert(e0 && e1);
@@ -38,13 +39,15 @@ static std::shared_ptr<Pattern> tensorPattern(unsigned tensorNum) {
return std::make_shared<Pattern>(tensorNum);
}
-static std::shared_ptr<Pattern> addfPattern(std::shared_ptr<Pattern> e0,
- std::shared_ptr<Pattern> e1) {
+static std::shared_ptr<Pattern>
+addfPattern(const std::shared_ptr<Pattern> &e0,
+ const std::shared_ptr<Pattern> &e1) {
return std::make_shared<Pattern>(Kind::kAddF, e0, e1);
}
-static std::shared_ptr<Pattern> mulfPattern(std::shared_ptr<Pattern> e0,
- std::shared_ptr<Pattern> e1) {
+static std::shared_ptr<Pattern>
+mulfPattern(const std::shared_ptr<Pattern> &e0,
+ const std::shared_ptr<Pattern> &e1) {
return std::make_shared<Pattern>(Kind::kMulF, e0, e1);
}
@@ -84,8 +87,8 @@ class MergerTestBase : public ::testing::Test {
/// groups of lattice points should be ordered with respect to other groups,
/// but there is no required ordering within groups.
bool latPointWithinRange(unsigned s, unsigned p, unsigned n,
- std::shared_ptr<Pattern> pattern,
- llvm::BitVector bits) {
+ const std::shared_ptr<Pattern> &pattern,
+ const llvm::BitVector &bits) {
for (unsigned i = p; i < p + n; ++i) {
if (compareExpression(merger.lat(merger.set(s)[i]).exp, pattern) &&
compareBits(s, i, bits))
@@ -110,7 +113,7 @@ class MergerTestBase : public ::testing::Test {
/// Converts a vector of (loop, tensor) pairs to a bitvector with the
/// corresponding bits set.
llvm::BitVector
- loopsToBits(std::vector<std::pair<unsigned, unsigned>> loops) {
+ loopsToBits(const std::vector<std::pair<unsigned, unsigned>> &loops) {
llvm::BitVector testBits = llvm::BitVector(numTensors + 1, false);
for (auto l : loops) {
auto loop = std::get<0>(l);
@@ -121,7 +124,7 @@ class MergerTestBase : public ::testing::Test {
}
/// Returns true if the bits of lattice point p in set s match the given bits.
- bool compareBits(unsigned s, unsigned p, llvm::BitVector bits) {
+ bool compareBits(unsigned s, unsigned p, const llvm::BitVector &bits) {
return merger.lat(merger.set(s)[p]).bits == bits;
}
@@ -136,7 +139,7 @@ class MergerTestBase : public ::testing::Test {
/// children are equal.
/// - Expressions with Kind invariant or tensor are equal if they have the
/// same expression id.
- bool compareExpression(unsigned e, std::shared_ptr<Pattern> pattern) {
+ bool compareExpression(unsigned e, const std::shared_ptr<Pattern> &pattern) {
auto tensorExp = merger.exp(e);
if (tensorExp.kind != pattern->kind)
return false;
More information about the Mlir-commits
mailing list