diff --git a/mlir/examples/Linalg/Linalg1/lib/SliceOp.cpp b/mlir/examples/Linalg/Linalg1/lib/SliceOp.cpp index 818a770c58dd..b7337a1c5cd5 100644 --- a/mlir/examples/Linalg/Linalg1/lib/SliceOp.cpp +++ b/mlir/examples/Linalg/Linalg1/lib/SliceOp.cpp @@ -93,7 +93,7 @@ void linalg::SliceOp::print(OpAsmPrinter *p) { *p << "*"; } else { auto *v = getIndexing(); - if (isa_nonnull(v->getDefiningOp())) { + if (isa_and_nonnull(v->getDefiningOp())) { *p << *v << ".."; } else { *p << *v; diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index 7007f81e4712..aacf9ee1117d 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -532,9 +532,9 @@ template T dyn_cast_or_null(Operation *op) { return op ? op->dyn_cast() : T(); } -/// Provide isa_nonnull functionality for Operation casts, i.e. if the operation -/// is non-null and a class of 'T'. -template bool isa_nonnull(Operation *op) { +/// Provide isa_and_nonnull functionality for Operation casts, i.e. if the +/// operation is non-null and a class of 'T'. +template bool isa_and_nonnull(Operation *op) { return op && op->isa(); } diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp index 0ff7db22e810..63c2b8906285 100644 --- a/mlir/lib/AffineOps/AffineOps.cpp +++ b/mlir/lib/AffineOps/AffineOps.cpp @@ -317,7 +317,7 @@ static llvm::SetVector indicesFromAffineApplyOp(ArrayRef operands) { llvm::SetVector res; for (auto en : llvm::enumerate(operands)) - if (isa_nonnull(en.value()->getDefiningOp())) + if (isa_and_nonnull(en.value()->getDefiningOp())) res.insert(en.index()); return res; } @@ -531,7 +531,7 @@ static void composeAffineMapAndOperands(AffineMap *map, void mlir::fullyComposeAffineMapAndOperands( AffineMap *map, SmallVectorImpl *operands) { while (llvm::any_of(*operands, [](Value *v) { - return isa_nonnull(v->getDefiningOp()); + return isa_and_nonnull(v->getDefiningOp()); })) { composeAffineMapAndOperands(map, operands); } diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp index 53120af85746..ad9a87b69b38 100644 --- a/mlir/lib/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Analysis/AffineAnalysis.cpp @@ -64,7 +64,7 @@ void mlir::getReachableAffineApplyOps( auto *opInst = state.value->getDefiningOp(); // Note: getDefiningOp will return nullptr if the operand is not an // Operation (i.e. block argument), which is a terminator for the search. - if (!isa_nonnull(opInst)) { + if (!isa_and_nonnull(opInst)) { worklist.pop_back(); continue; } diff --git a/mlir/lib/StandardOps/Ops.cpp b/mlir/lib/StandardOps/Ops.cpp index 38a86c4ea35d..99f93d1cc471 100644 --- a/mlir/lib/StandardOps/Ops.cpp +++ b/mlir/lib/StandardOps/Ops.cpp @@ -1094,7 +1094,7 @@ struct SimplifyDeadDealloc : public RewritePattern { // Check that the memref operand's defining operation is an AllocOp. Value *memref = dealloc.getMemRef(); Operation *defOp = memref->getDefiningOp(); - if (!isa_nonnull(defOp)) + if (!isa_and_nonnull(defOp)) return matchFailure(); // Check that all of the uses of the AllocOp are other DeallocOps. diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 011423bcc550..a69836c86532 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -2243,7 +2243,7 @@ public: continue; // Use list expected to match the dep graph info. auto *op = memref->getDefiningOp(); - if (isa_nonnull(op)) + if (isa_and_nonnull(op)) op->erase(); } }