From dfcc403b2d78e9b2e8aec788445b9add5ed0ac7a Mon Sep 17 00:00:00 2001 From: Uday Bondhugula Date: Thu, 16 Apr 2020 18:57:32 +0530 Subject: [PATCH] [MLIR] NFC use Operation::getParentWithTrait in alloca verifier Use recently added accessor Operation::getParentWithTrait in alloca verifier. Differential Revision: https://reviews.llvm.org/D78296 --- mlir/lib/Dialect/StandardOps/IR/Ops.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp index 53870e414c1993..452dade61e3284 100644 --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -324,14 +324,11 @@ static LogicalResult verify(AllocLikeOp op) { return success(); // An alloca op needs to have an ancestor with an allocation scope trait. - auto *parentOp = op.getParentOp(); - while (parentOp) { - if (parentOp->template hasTrait()) - return success(); - parentOp = parentOp->getParentOp(); - } - return op.emitOpError( - "requires an ancestor op with AutomaticAllocationScope trait"); + if (!op.template getParentWithTrait()) + return op.emitOpError( + "requires an ancestor op with AutomaticAllocationScope trait"); + + return success(); } namespace {