[PATCH] D78296: [MLIR] NFC use Operation::getParentWithTrait in alloca verifier

Uday Bondhugula via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 08:54:42 PDT 2020


bondhugula updated this revision to Diff 258063.
bondhugula added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78296/new/

https://reviews.llvm.org/D78296

Files:
  mlir/lib/Dialect/StandardOps/IR/Ops.cpp


Index: mlir/lib/Dialect/StandardOps/IR/Ops.cpp
===================================================================
--- mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -324,14 +324,11 @@
     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<OpTrait::AutomaticAllocationScope>())
-      return success();
-    parentOp = parentOp->getParentOp();
-  }
-  return op.emitOpError(
-      "requires an ancestor op with AutomaticAllocationScope trait");
+  if (!op.template getParentWithTrait<OpTrait::AutomaticAllocationScope>())
+    return op.emitOpError(
+        "requires an ancestor op with AutomaticAllocationScope trait");
+
+  return success();
 }
 
 namespace {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78296.258063.patch
Type: text/x-patch
Size: 849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/8fd49969/attachment-0001.bin>


More information about the llvm-commits mailing list