Skip to content

Commit 4a88b90

Browse files
authored
[MLIR] Fix dangling llvm::function_ref references (#114950)
1 parent 1715549 commit 4a88b90

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct BufferResultsToOutParamsOpts {
163163

164164
// Filter function; returns true if the function should be converted.
165165
// Defaults to true, i.e. all functions are converted.
166-
llvm::function_ref<bool(func::FuncOp *)> filterFn = [](func::FuncOp *func) {
166+
std::function<bool(func::FuncOp *)> filterFn = [](func::FuncOp *func) {
167167
return true;
168168
};
169169

mlir/lib/Dialect/SCF/IR/SCF.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,13 +1084,12 @@ struct ForOpTensorCastFolder : public OpRewritePattern<ForOp> {
10841084
continue;
10851085

10861086
// Create a new ForOp with that iter operand replaced.
1087-
ValueTypeCastFnTy castFn = [](OpBuilder &b, Location loc, Type type,
1088-
Value source) {
1089-
return b.create<tensor::CastOp>(loc, type, source);
1090-
};
10911087
rewriter.replaceOp(
1092-
op, replaceAndCastForOpIterArg(rewriter, op, iterOpOperand,
1093-
incomingCast.getSource(), castFn));
1088+
op, replaceAndCastForOpIterArg(
1089+
rewriter, op, iterOpOperand, incomingCast.getSource(),
1090+
[](OpBuilder &b, Location loc, Type type, Value source) {
1091+
return b.create<tensor::CastOp>(loc, type, source);
1092+
}));
10941093
return success();
10951094
}
10961095
return failure();

mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,8 @@ ConstantIntRanges
319319
mlir::intrange::inferCeilDivU(ArrayRef<ConstantIntRanges> argRanges) {
320320
const ConstantIntRanges &lhs = argRanges[0], &rhs = argRanges[1];
321321

322-
DivisionFixupFn ceilDivUIFix =
323-
[](const APInt &lhs, const APInt &rhs,
324-
const APInt &result) -> std::optional<APInt> {
322+
auto ceilDivUIFix = [](const APInt &lhs, const APInt &rhs,
323+
const APInt &result) -> std::optional<APInt> {
325324
if (!lhs.urem(rhs).isZero()) {
326325
bool overflowed = false;
327326
APInt corrected =
@@ -368,9 +367,8 @@ ConstantIntRanges
368367
mlir::intrange::inferCeilDivS(ArrayRef<ConstantIntRanges> argRanges) {
369368
const ConstantIntRanges &lhs = argRanges[0], &rhs = argRanges[1];
370369

371-
DivisionFixupFn ceilDivSIFix =
372-
[](const APInt &lhs, const APInt &rhs,
373-
const APInt &result) -> std::optional<APInt> {
370+
auto ceilDivSIFix = [](const APInt &lhs, const APInt &rhs,
371+
const APInt &result) -> std::optional<APInt> {
374372
if (!lhs.srem(rhs).isZero() && lhs.isNonNegative() == rhs.isNonNegative()) {
375373
bool overflowed = false;
376374
APInt corrected =
@@ -386,9 +384,8 @@ ConstantIntRanges
386384
mlir::intrange::inferFloorDivS(ArrayRef<ConstantIntRanges> argRanges) {
387385
const ConstantIntRanges &lhs = argRanges[0], &rhs = argRanges[1];
388386

389-
DivisionFixupFn floorDivSIFix =
390-
[](const APInt &lhs, const APInt &rhs,
391-
const APInt &result) -> std::optional<APInt> {
387+
auto floorDivSIFix = [](const APInt &lhs, const APInt &rhs,
388+
const APInt &result) -> std::optional<APInt> {
392389
if (!lhs.srem(rhs).isZero() && lhs.isNonNegative() != rhs.isNonNegative()) {
393390
bool overflowed = false;
394391
APInt corrected =
@@ -603,8 +600,7 @@ ConstantIntRanges
603600
mlir::intrange::inferShrS(ArrayRef<ConstantIntRanges> argRanges) {
604601
const ConstantIntRanges &lhs = argRanges[0], &rhs = argRanges[1];
605602

606-
ConstArithFn ashr = [](const APInt &l,
607-
const APInt &r) -> std::optional<APInt> {
603+
auto ashr = [](const APInt &l, const APInt &r) -> std::optional<APInt> {
608604
return r.uge(r.getBitWidth()) ? std::optional<APInt>() : l.ashr(r);
609605
};
610606

@@ -616,8 +612,7 @@ ConstantIntRanges
616612
mlir::intrange::inferShrU(ArrayRef<ConstantIntRanges> argRanges) {
617613
const ConstantIntRanges &lhs = argRanges[0], &rhs = argRanges[1];
618614

619-
ConstArithFn lshr = [](const APInt &l,
620-
const APInt &r) -> std::optional<APInt> {
615+
auto lshr = [](const APInt &l, const APInt &r) -> std::optional<APInt> {
621616
return r.uge(r.getBitWidth()) ? std::optional<APInt>() : l.lshr(r);
622617
};
623618
return minMaxBy(lshr, {lhs.umin(), lhs.umax()}, {rhs.umin(), rhs.umax()},

0 commit comments

Comments
 (0)