Skip to content

Commit 1fc096a

Browse files
committed
Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC)
Reviewed By: Mogball Differential Revision: https://reviews.llvm.org/D116250
1 parent b11510d commit 1fc096a

File tree

71 files changed

+500
-377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+500
-377
lines changed

mlir/include/mlir/Analysis/NestedMatcher.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ class NestedPatternContext {
180180
namespace matcher {
181181
// Syntactic sugar NestedPattern builder functions.
182182
NestedPattern Op(FilterFunctionType filter = defaultFilterFunction);
183-
NestedPattern If(NestedPattern child);
184-
NestedPattern If(FilterFunctionType filter, NestedPattern child);
183+
NestedPattern If(const NestedPattern &child);
184+
NestedPattern If(const FilterFunctionType &filter, const NestedPattern &child);
185185
NestedPattern If(ArrayRef<NestedPattern> nested = {});
186-
NestedPattern If(FilterFunctionType filter,
186+
NestedPattern If(const FilterFunctionType &filter,
187187
ArrayRef<NestedPattern> nested = {});
188-
NestedPattern For(NestedPattern child);
189-
NestedPattern For(FilterFunctionType filter, NestedPattern child);
188+
NestedPattern For(const NestedPattern &child);
189+
NestedPattern For(const FilterFunctionType &filter, const NestedPattern &child);
190190
NestedPattern For(ArrayRef<NestedPattern> nested = {});
191-
NestedPattern For(FilterFunctionType filter,
191+
NestedPattern For(const FilterFunctionType &filter,
192192
ArrayRef<NestedPattern> nested = {});
193193

194194
bool isParallelLoop(Operation &op);

mlir/include/mlir/Dialect/Async/Transforms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using AsyncMinTaskSizeComputationFunction =
3232
/// operations.
3333
void populateAsyncParallelForPatterns(
3434
RewritePatternSet &patterns, bool asyncDispatch, int32_t numWorkerThreads,
35-
AsyncMinTaskSizeComputationFunction computeMinTaskSize);
35+
const AsyncMinTaskSizeComputationFunction &computeMinTaskSize);
3636

3737
} // namespace async
3838
} // namespace mlir

mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class BufferizationState {
352352
/// { 2, 7, 8, 5 }
353353
llvm::SetVector<Value>
354354
findValueInReverseUseDefChain(Value value,
355-
std::function<bool(Value)> condition);
355+
llvm::function_ref<bool(Value)> condition);
356356

357357
/// Find the Value of the last preceding write of a given Value.
358358
///

mlir/include/mlir/Dialect/Linalg/Passes.h

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -82,70 +82,70 @@ std::unique_ptr<Pass> createLinalgDetensorizePass();
8282
//===----------------------------------------------------------------------===//
8383
/// Create a LinalgStrategyTileAndFusePass.
8484
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyTileAndFusePass(
85-
StringRef opName = "", linalg::LinalgTilingAndFusionOptions opt = {},
86-
linalg::LinalgTransformationFilter filter =
85+
StringRef opName = "", const linalg::LinalgTilingAndFusionOptions &opt = {},
86+
const linalg::LinalgTransformationFilter &filter =
8787
linalg::LinalgTransformationFilter());
8888

8989
/// Create a LinalgStrategyTilePass.
9090
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyTilePass(
9191
StringRef opName = "",
92-
linalg::LinalgTilingOptions opt = linalg::LinalgTilingOptions(),
93-
linalg::LinalgTransformationFilter filter =
92+
const linalg::LinalgTilingOptions &opt = linalg::LinalgTilingOptions(),
93+
const linalg::LinalgTransformationFilter &filter =
9494
linalg::LinalgTransformationFilter());
9595

9696
/// Create a LinalgStrategyPadPass.
9797
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyPadPass(
9898
StringRef opName = "",
99-
linalg::LinalgPaddingOptions opt = linalg::LinalgPaddingOptions(),
100-
linalg::LinalgTransformationFilter filter =
99+
const linalg::LinalgPaddingOptions &opt = linalg::LinalgPaddingOptions(),
100+
const linalg::LinalgTransformationFilter &filter =
101101
linalg::LinalgTransformationFilter());
102102

103103
/// Create a LinalgStrategyPromotePass.
104104
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyPromotePass(
105105
StringRef opName = "",
106-
linalg::LinalgPromotionOptions opt = linalg::LinalgPromotionOptions(),
107-
linalg::LinalgTransformationFilter filter =
106+
const linalg::LinalgPromotionOptions &opt =
107+
linalg::LinalgPromotionOptions(),
108+
const linalg::LinalgTransformationFilter &filter =
108109
linalg::LinalgTransformationFilter());
109110

110111
/// Create a LinalgStrategyGeneralizePass.
111-
std::unique_ptr<OperationPass<FuncOp>>
112-
createLinalgStrategyGeneralizePass(StringRef opName = "",
113-
linalg::LinalgTransformationFilter filter =
114-
linalg::LinalgTransformationFilter());
112+
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyGeneralizePass(
113+
StringRef opName = "", const linalg::LinalgTransformationFilter &filter =
114+
linalg::LinalgTransformationFilter());
115115

116116
/// Create a LinalgStrategyDecomposePass.
117117
// TODO: if/when we need finer control add an `opName` parameter.
118-
std::unique_ptr<OperationPass<FuncOp>>
119-
createLinalgStrategyDecomposePass(linalg::LinalgTransformationFilter filter =
120-
linalg::LinalgTransformationFilter());
118+
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyDecomposePass(
119+
const linalg::LinalgTransformationFilter &filter =
120+
linalg::LinalgTransformationFilter());
121121

122122
/// Create a LinalgStrategyInterchangePass.
123-
std::unique_ptr<OperationPass<FuncOp>>
124-
createLinalgStrategyInterchangePass(ArrayRef<int64_t> iteratorInterchange = {},
125-
linalg::LinalgTransformationFilter filter =
126-
linalg::LinalgTransformationFilter());
123+
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyInterchangePass(
124+
ArrayRef<int64_t> iteratorInterchange = {},
125+
const linalg::LinalgTransformationFilter &filter =
126+
linalg::LinalgTransformationFilter());
127127

128128
/// Create a LinalgStrategyVectorizePass.
129-
std::unique_ptr<OperationPass<FuncOp>>
130-
createLinalgStrategyVectorizePass(StringRef opName = "",
131-
linalg::LinalgVectorizationOptions opt =
132-
linalg::LinalgVectorizationOptions(),
133-
linalg::LinalgTransformationFilter filter =
134-
linalg::LinalgTransformationFilter(),
135-
bool padVectorize = false);
129+
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyVectorizePass(
130+
StringRef opName = "",
131+
linalg::LinalgVectorizationOptions opt =
132+
linalg::LinalgVectorizationOptions(),
133+
const linalg::LinalgTransformationFilter &filter =
134+
linalg::LinalgTransformationFilter(),
135+
bool padVectorize = false);
136136

137137
/// Create a LinalgStrategyEnablePass.
138138
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyEnablePass(
139139
linalg::LinalgEnablingOptions opt = linalg::LinalgEnablingOptions(),
140-
linalg::LinalgTransformationFilter filter =
140+
const linalg::LinalgTransformationFilter &filter =
141141
linalg::LinalgTransformationFilter());
142142

143143
/// Create a LinalgStrategyLowerVectorsPass.
144-
std::unique_ptr<OperationPass<FuncOp>>
145-
createLinalgStrategyLowerVectorsPass(linalg::LinalgVectorLoweringOptions opt =
146-
linalg::LinalgVectorLoweringOptions(),
147-
linalg::LinalgTransformationFilter filter =
148-
linalg::LinalgTransformationFilter());
144+
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyLowerVectorsPass(
145+
linalg::LinalgVectorLoweringOptions opt =
146+
linalg::LinalgVectorLoweringOptions(),
147+
const linalg::LinalgTransformationFilter &filter =
148+
linalg::LinalgTransformationFilter());
149149

150150
/// Create a LinalgStrategyRemoveMarkersPass.
151151
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyRemoveMarkersPass();

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ using ControlElementwiseOpsFusionFn =
7070
/// loop in the generic op.
7171
void populateFoldReshapeOpsByExpansionPatterns(
7272
RewritePatternSet &patterns,
73-
ControlElementwiseOpsFusionFn controlFoldingReshapes = skipUnitDimReshape);
73+
const ControlElementwiseOpsFusionFn &controlFoldingReshapes =
74+
skipUnitDimReshape);
7475

7576
/// Patterns to fold a collapsing (expanding) tensor_reshape operation with its
7677
/// producer (consumer) generic operation by linearizing the indexing map used
@@ -356,7 +357,7 @@ struct PromotionInfo {
356357
};
357358
FailureOr<PromotionInfo>
358359
promoteSubviewAsNewBuffer(OpBuilder &b, Location loc, memref::SubViewOp subView,
359-
AllocBufferCallbackFn allocationFn,
360+
const AllocBufferCallbackFn &allocationFn,
360361
DataLayout &layout);
361362

362363
/// Promotes the `subViews` into a new buffer allocated at the insertion point
@@ -370,7 +371,7 @@ promoteSubviewAsNewBuffer(OpBuilder &b, Location loc, memref::SubViewOp subView,
370371
/// Returns the modified linalg op (the modification happens in place) as well
371372
/// as all the copy ops created.
372373
FailureOr<LinalgOp> promoteSubViews(OpBuilder &b, LinalgOp op,
373-
LinalgPromotionOptions options);
374+
const LinalgPromotionOptions &options);
374375

375376
/// Emit a suitable vector form for a Linalg op with fully static shape.
376377
LogicalResult vectorizeLinalgOp(OpBuilder &builder, Operation *op,
@@ -437,7 +438,7 @@ struct LinalgTransformationFilter {
437438
Optional<StringAttr> replacement = None);
438439

439440
explicit LinalgTransformationFilter(
440-
FilterFunction f, ArrayRef<StringAttr> matchDisjunction = {},
441+
const FilterFunction &f, ArrayRef<StringAttr> matchDisjunction = {},
441442
Optional<StringAttr> replacement = None);
442443

443444
LinalgTransformationFilter(LinalgTransformationFilter &&) = default;
@@ -1180,7 +1181,7 @@ struct LinalgLoweringPattern : public RewritePattern {
11801181
/// linalg.generic ops.
11811182
void populateLinalgNamedOpsGeneralizationPatterns(
11821183
RewritePatternSet &patterns,
1183-
LinalgTransformationFilter filter = LinalgTransformationFilter());
1184+
const LinalgTransformationFilter &filter = LinalgTransformationFilter());
11841185

11851186
/// Linalg decompose convolutions patterns
11861187

@@ -1189,7 +1190,7 @@ void populateLinalgNamedOpsGeneralizationPatterns(
11891190
/// vectorize the low-D convolution ops.
11901191
void populateDecomposeConvolutionPatterns(
11911192
RewritePatternSet &patterns,
1192-
LinalgTransformationFilter filter = LinalgTransformationFilter(),
1193+
const LinalgTransformationFilter &filter = LinalgTransformationFilter(),
11931194
PatternBenefit benefit = 1);
11941195

11951196
/// Linalg distribution patterns

mlir/include/mlir/IR/AffineMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class AffineMap {
182182

183183
/// Walk all of the AffineExpr's in this mapping. Each node in an expression
184184
/// tree is visited in postorder.
185-
void walkExprs(std::function<void(AffineExpr)> callback) const;
185+
void walkExprs(llvm::function_ref<void(AffineExpr)> callback) const;
186186

187187
/// This method substitutes any uses of dimensions and symbols (e.g.
188188
/// dim#0 with dimReplacements[0]) in subexpressions and returns the modified

mlir/include/mlir/IR/Dialect.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ class DialectRegistry {
317317
/// Add a new dialect constructor to the registry. The constructor must be
318318
/// calling MLIRContext::getOrLoadDialect in order for the context to take
319319
/// ownership of the dialect and for delayed interface registration to happen.
320-
void insert(TypeID typeID, StringRef name, DialectAllocatorFunction ctor);
320+
void insert(TypeID typeID, StringRef name,
321+
const DialectAllocatorFunction &ctor);
321322

322323
/// Return an allocation function for constructing the dialect identified by
323324
/// its namespace, or nullptr if the namespace is not in this registry.
@@ -397,13 +398,13 @@ class DialectRegistry {
397398
/// Add an interface constructed with the given allocation function to the
398399
/// dialect identified by its namespace.
399400
void addDialectInterface(StringRef dialectName, TypeID interfaceTypeID,
400-
DialectInterfaceAllocatorFunction allocator);
401+
const DialectInterfaceAllocatorFunction &allocator);
401402

402403
/// Add an attribute/operation/type interface constructible with the given
403404
/// allocation function to the dialect identified by its namespace.
404405
void addObjectInterface(StringRef dialectName, TypeID objectID,
405406
TypeID interfaceTypeID,
406-
ObjectInterfaceAllocatorFunction allocator);
407+
const ObjectInterfaceAllocatorFunction &allocator);
407408

408409
/// Add an external model for an attribute/type interface to the dialect
409410
/// identified by its namespace.

mlir/include/mlir/Reducer/ReductionNode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ReductionNode {
4848

4949
using Range = std::pair<int, int>;
5050

51-
ReductionNode(ReductionNode *parent, std::vector<Range> range,
51+
ReductionNode(ReductionNode *parent, const std::vector<Range> &range,
5252
llvm::SpecificBumpPtrAllocator<ReductionNode> &allocator);
5353

5454
ReductionNode *getParent() const { return parent; }

mlir/include/mlir/TableGen/GenInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class GenInfo {
6464
/// // At namespace scope.
6565
/// static GenRegistration Print("print", "Print records", [](...){...});
6666
struct GenRegistration {
67-
GenRegistration(StringRef arg, StringRef description, GenFunction function);
67+
GenRegistration(StringRef arg, StringRef description,
68+
const GenFunction &function);
6869
};
6970

7071
} // namespace mlir

mlir/include/mlir/TableGen/Pattern.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ class SymbolInfoMap {
398398
// with index `argIndex` for operator `op`.
399399
const_iterator findBoundSymbol(StringRef key, DagNode node,
400400
const Operator &op, int argIndex) const;
401-
const_iterator findBoundSymbol(StringRef key, SymbolInfo symbolInfo) const;
401+
const_iterator findBoundSymbol(StringRef key,
402+
const SymbolInfo &symbolInfo) const;
402403

403404
// Returns the bounds of a range that includes all the elements which
404405
// bind to the `key`.

0 commit comments

Comments
 (0)