Skip to content

Commit c989f85

Browse files
committed
[MLIR] Apply clang-tidy fixes for performance-unnecessary-value-param in ValueBoundsOpInterface.cpp (NFC)
1 parent 23d1ec6 commit c989f85

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class ValueBoundsConstraintSet
217217
/// `closedUB` is set to "true", upper bounds are also closed.
218218
static FailureOr<int64_t>
219219
computeConstantBound(presburger::BoundType type, const Variable &var,
220-
StopConditionFn stopCondition = nullptr,
220+
const StopConditionFn &stopCondition = nullptr,
221221
bool closedUB = false);
222222

223223
/// Compute a constant delta between the given two values. Return "failure"
@@ -282,18 +282,18 @@ class ValueBoundsConstraintSet
282282
///
283283
/// Slice are non-overlapping if the above constraint is not satisfied for
284284
/// at least one dimension.
285-
static FailureOr<bool> areOverlappingSlices(MLIRContext *ctx,
286-
HyperrectangularSlice slice1,
287-
HyperrectangularSlice slice2);
285+
static FailureOr<bool>
286+
areOverlappingSlices(MLIRContext *ctx, const HyperrectangularSlice &slice1,
287+
const HyperrectangularSlice &slice2);
288288

289289
/// Return "true" if the given slices are guaranteed to be equivalent.
290290
/// Return "false" if the given slices are guaranteed to be non-equivalent.
291291
/// Return "failure" if unknown.
292292
///
293293
/// Slices are equivalent if their offsets, sizes and strices are equal.
294-
static FailureOr<bool> areEquivalentSlices(MLIRContext *ctx,
295-
HyperrectangularSlice slice1,
296-
HyperrectangularSlice slice2);
294+
static FailureOr<bool>
295+
areEquivalentSlices(MLIRContext *ctx, const HyperrectangularSlice &slice1,
296+
const HyperrectangularSlice &slice2);
297297

298298
/// Add a bound for the given index-typed value or shaped value. This function
299299
/// returns a builder that adds the bound.
@@ -326,7 +326,8 @@ class ValueBoundsConstraintSet
326326
/// An index-typed value or the dimension of a shaped-type value.
327327
using ValueDim = std::pair<Value, int64_t>;
328328

329-
ValueBoundsConstraintSet(MLIRContext *ctx, StopConditionFn stopCondition,
329+
ValueBoundsConstraintSet(MLIRContext *ctx,
330+
const StopConditionFn &stopCondition,
330331
bool addConservativeSemiAffineBounds = false);
331332

332333
/// Return "true" if, based on the current state of the constraint system,
@@ -401,7 +402,8 @@ class ValueBoundsConstraintSet
401402
/// Insert the given affine map and its bound operands as a new column in the
402403
/// constraint system. Return the position of the new column. Any operands
403404
/// that were not analyzed yet are put on the worklist.
404-
int64_t insert(AffineMap map, ValueDimList operands, bool isSymbol = true);
405+
int64_t insert(AffineMap map, const ValueDimList &operands,
406+
bool isSymbol = true);
405407
int64_t insert(const Variable &var, bool isSymbol = true);
406408

407409
/// Project out the given column in the constraint set.

mlir/lib/Interfaces/ValueBoundsOpInterface.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include <utility>
10+
911
#include "mlir/Interfaces/ValueBoundsOpInterface.h"
1012

1113
#include "mlir/IR/BuiltinTypes.h"
@@ -151,7 +153,7 @@ ValueBoundsConstraintSet::Variable::Variable(AffineMap map,
151153
[](Value v) { return Variable(v); })) {}
152154

153155
ValueBoundsConstraintSet::ValueBoundsConstraintSet(
154-
MLIRContext *ctx, StopConditionFn stopCondition,
156+
MLIRContext *ctx, const StopConditionFn &stopCondition,
155157
bool addConservativeSemiAffineBounds)
156158
: builder(ctx), stopCondition(stopCondition),
157159
addConservativeSemiAffineBounds(addConservativeSemiAffineBounds) {
@@ -302,7 +304,8 @@ int64_t ValueBoundsConstraintSet::insert(bool isSymbol) {
302304
return pos;
303305
}
304306

305-
int64_t ValueBoundsConstraintSet::insert(AffineMap map, ValueDimList operands,
307+
int64_t ValueBoundsConstraintSet::insert(AffineMap map,
308+
const ValueDimList &operands,
306309
bool isSymbol) {
307310
assert(map.getNumResults() == 1 && "expected affine map with one result");
308311
int64_t pos = insert(isSymbol);
@@ -629,7 +632,7 @@ LogicalResult ValueBoundsConstraintSet::computeIndependentBound(
629632

630633
FailureOr<int64_t> ValueBoundsConstraintSet::computeConstantBound(
631634
presburger::BoundType type, const Variable &var,
632-
StopConditionFn stopCondition, bool closedUB) {
635+
const StopConditionFn &stopCondition, bool closedUB) {
633636
// Default stop condition if none was specified: Keep adding constraints until
634637
// a bound could be computed.
635638
int64_t pos = 0;
@@ -666,7 +669,7 @@ void ValueBoundsConstraintSet::populateConstraints(Value value,
666669

667670
int64_t ValueBoundsConstraintSet::populateConstraints(AffineMap map,
668671
ValueDimList operands) {
669-
int64_t pos = insert(map, operands, /*isSymbol=*/false);
672+
int64_t pos = insert(map, std::move(operands), /*isSymbol=*/false);
670673
// Process the backward slice of `operands` (i.e., reverse use-def chain)
671674
// until `stopCondition` is met.
672675
processWorklist();
@@ -826,10 +829,9 @@ FailureOr<bool> ValueBoundsConstraintSet::areEqual(const Variable &var1,
826829
return strongCompare(var1, ComparisonOperator::EQ, var2);
827830
}
828831

829-
FailureOr<bool>
830-
ValueBoundsConstraintSet::areOverlappingSlices(MLIRContext *ctx,
831-
HyperrectangularSlice slice1,
832-
HyperrectangularSlice slice2) {
832+
FailureOr<bool> ValueBoundsConstraintSet::areOverlappingSlices(
833+
MLIRContext *ctx, const HyperrectangularSlice &slice1,
834+
const HyperrectangularSlice &slice2) {
833835
assert(slice1.getMixedOffsets().size() == slice2.getMixedOffsets().size() &&
834836
"expected slices of same rank");
835837
assert(slice1.getMixedSizes().size() == slice2.getMixedSizes().size() &&
@@ -891,10 +893,9 @@ ValueBoundsConstraintSet::areOverlappingSlices(MLIRContext *ctx,
891893
return true;
892894
}
893895

894-
FailureOr<bool>
895-
ValueBoundsConstraintSet::areEquivalentSlices(MLIRContext *ctx,
896-
HyperrectangularSlice slice1,
897-
HyperrectangularSlice slice2) {
896+
FailureOr<bool> ValueBoundsConstraintSet::areEquivalentSlices(
897+
MLIRContext *ctx, const HyperrectangularSlice &slice1,
898+
const HyperrectangularSlice &slice2) {
898899
assert(slice1.getMixedOffsets().size() == slice2.getMixedOffsets().size() &&
899900
"expected slices of same rank");
900901
assert(slice1.getMixedSizes().size() == slice2.getMixedSizes().size() &&

0 commit comments

Comments
 (0)